Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
7dab62ec
K
kotlin
项目概览
硅谷海盗
/
kotlin
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kotlin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7dab62ec
编写于
5月 31, 2012
作者:
S
Svetlana Isakova
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
KT-2125 Inconsistent error message on UNSAFE_CALL
#KT-2125 fixed
上级
423ed30e
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
46 addition
and
28 deletion
+46
-28
compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java
...rc/org/jetbrains/jet/lang/resolve/calls/CallResolver.java
+11
-4
compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ResolutionStatus.java
...rg/jetbrains/jet/lang/resolve/calls/ResolutionStatus.java
+3
-1
compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ResolutionTask.java
.../org/jetbrains/jet/lang/resolve/calls/ResolutionTask.java
+1
-8
compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ValueArgumentsToParametersMapper.java
.../lang/resolve/calls/ValueArgumentsToParametersMapper.java
+13
-11
compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java
.../lang/types/expressions/BasicExpressionTypingVisitor.java
+6
-4
compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2125.jet
...Data/diagnostics/tests/nullabilityAndAutoCasts/kt2125.jet
+12
-0
未找到文件。
compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java
浏览文件 @
7dab62ec
...
...
@@ -288,7 +288,7 @@ public class CallResolver {
return
results
;
}
if
(
traceForFirstNonemptyCandidateSet
==
null
&&
!
task
.
getCandidates
().
isEmpty
())
{
if
(
traceForFirstNonemptyCandidateSet
==
null
&&
!
task
.
getCandidates
().
isEmpty
()
&&
!
results
.
isNothing
()
)
{
traceForFirstNonemptyCandidateSet
=
temporaryTrace
;
resultsForFirstNonemptyCandidateSet
=
results
;
}
...
...
@@ -380,9 +380,11 @@ public class CallResolver {
}
else
{
assert
status
!=
UNKNOWN_STATUS
:
"No resolution for "
+
candidateCall
.
getCandidateDescriptor
();
if
(
candidateCall
.
getStatus
()
!=
STRONG_ERROR
)
{
failedCandidates
.
add
(
candidateCall
);
}
}
}
OverloadResolutionResultsImpl
<
F
>
results
=
computeResultAndReportErrors
(
task
.
trace
,
task
.
tracing
,
successfulCandidates
,
failedCandidates
);
if
(!
results
.
isSingleResult
())
{
...
...
@@ -414,8 +416,13 @@ public class CallResolver {
argumentMappingStatus
=
ValueArgumentsToParametersMapper
.
mapValueArgumentsToParameters
(
context
.
call
,
context
.
tracing
,
candidateCall
,
unmappedArguments
);
if
(!
argumentMappingStatus
.
isSuccess
())
{
if
(
argumentMappingStatus
==
ValueArgumentsToParametersMapper
.
Status
.
STRONG_ERROR
)
{
candidateCall
.
addStatus
(
STRONG_ERROR
);
}
else
{
candidateCall
.
addStatus
(
OTHER_ERROR
);
if
(
argumentMappingStatus
==
ValueArgumentsToParametersMapper
.
Status
.
ERROR
)
{
}
if
(
argumentMappingStatus
!=
ValueArgumentsToParametersMapper
.
Status
.
WEAK_ERROR
)
{
checkTypesWithNoCallee
(
context
.
toBasic
());
return
;
}
...
...
compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ResolutionStatus.java
浏览文件 @
7dab62ec
...
...
@@ -25,12 +25,14 @@ public enum ResolutionStatus {
UNKNOWN_STATUS
,
UNSAFE_CALL_ERROR
,
OTHER_ERROR
,
STRONG_ERROR
,
SUCCESS
(
true
);
@SuppressWarnings
(
"unchecked"
)
public
static
final
EnumSet
<
ResolutionStatus
>[]
SEVERITY_LEVELS
=
new
EnumSet
[]
{
EnumSet
.
of
(
UNSAFE_CALL_ERROR
),
// weakest
EnumSet
.
of
(
OTHER_ERROR
),
// most severe
EnumSet
.
of
(
OTHER_ERROR
),
EnumSet
.
of
(
STRONG_ERROR
),
// most severe
};
private
final
boolean
success
;
...
...
compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ResolutionTask.java
浏览文件 @
7dab62ec
...
...
@@ -152,15 +152,8 @@ public class ResolutionTask<D extends CallableDescriptor, F extends D> extends R
@Override
public
void
noReceiverAllowed
(
@NotNull
BindingTrace
trace
)
{
if
(
reference
instanceof
JetSimpleNameExpression
)
{
//todo temporary hack
//should be stored that the reference is unresolved (and not trace the candidate descriptor)
trace
.
report
(
UNRESOLVED_REFERENCE
.
on
(
reference
));
}
else
{
trace
.
report
(
NO_RECEIVER_ADMITTED
.
on
(
reference
));
}
}
@Override
public
void
wrongNumberOfTypeArguments
(
@NotNull
BindingTrace
trace
,
int
expectedTypeArgumentCount
)
{
...
...
compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ValueArgumentsToParametersMapper.java
浏览文件 @
7dab62ec
...
...
@@ -34,6 +34,8 @@ import java.util.Set;
import
static
org
.
jetbrains
.
jet
.
lang
.
diagnostics
.
Errors
.*;
import
static
org
.
jetbrains
.
jet
.
lang
.
resolve
.
BindingContext
.
REFERENCE_TARGET
;
import
static
org
.
jetbrains
.
jet
.
lang
.
resolve
.
calls
.
ValueArgumentsToParametersMapper
.
Status
.*;
import
static
org
.
jetbrains
.
jet
.
lang
.
resolve
.
calls
.
ValueArgumentsToParametersMapper
.
Status
.
ERROR
;
import
static
org
.
jetbrains
.
jet
.
lang
.
resolve
.
calls
.
ValueArgumentsToParametersMapper
.
Status
.
STRONG_ERROR
;
/**
* @author abreslav
...
...
@@ -41,6 +43,7 @@ import static org.jetbrains.jet.lang.resolve.calls.ValueArgumentsToParametersMap
/*package*/
class
ValueArgumentsToParametersMapper
{
public
enum
Status
{
STRONG_ERROR
(
false
),
ERROR
(
false
),
WEAK_ERROR
(
false
),
OK
(
true
);
...
...
@@ -56,18 +59,12 @@ import static org.jetbrains.jet.lang.resolve.calls.ValueArgumentsToParametersMap
}
public
Status
compose
(
Status
other
)
{
switch
(
other
)
{
case
ERROR:
return
ERROR
;
case
WEAK_ERROR:
if
(
this
!=
ERROR
)
{
return
WEAK_ERROR
;
}
default
:
if
(
this
==
STRONG_ERROR
||
other
==
STRONG_ERROR
)
return
STRONG_ERROR
;
if
(
this
==
ERROR
||
other
==
ERROR
)
return
ERROR
;
if
(
this
==
WEAK_ERROR
||
other
==
WEAK_ERROR
)
return
WEAK_ERROR
;
return
this
;
}
}
}
public
static
<
D
extends
CallableDescriptor
>
Status
mapValueArgumentsToParameters
(
@NotNull
Call
call
,
...
...
@@ -220,8 +217,13 @@ import static org.jetbrains.jet.lang.resolve.calls.ValueArgumentsToParametersMap
}
if
(!
receiverParameter
.
exists
()
&&
receiverArgument
.
exists
())
{
tracing
.
noReceiverAllowed
(
temporaryTrace
);
if
(
call
.
getCalleeExpression
()
instanceof
JetSimpleNameExpression
)
{
status
=
STRONG_ERROR
;
}
else
{
status
=
ERROR
;
}
}
assert
(
candidateCall
.
getThisObject
().
exists
()
==
candidateCall
.
getResultingDescriptor
().
getExpectedThisObject
().
exists
())
:
"Shouldn't happen because of TaskPrioritizer: "
+
candidateCall
.
getCandidateDescriptor
();
...
...
compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java
浏览文件 @
7dab62ec
...
...
@@ -613,10 +613,10 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
private
JetType
getVariableType
(
@NotNull
JetSimpleNameExpression
nameExpression
,
@NotNull
ReceiverDescriptor
receiver
,
@Nullable
ASTNode
callOperationNode
,
@NotNull
ExpressionTypingContext
context
,
@NotNull
boolean
[]
result
)
{
TemporaryBindingTrace
t
emporaryTrac
e
=
TemporaryBindingTrace
.
create
(
context
.
trace
);
OverloadResolutionResults
<
VariableDescriptor
>
resolutionResult
=
context
.
replaceBindingTrace
(
t
emporaryTrac
e
).
resolveSimpleProperty
(
receiver
,
callOperationNode
,
nameExpression
);
TemporaryBindingTrace
t
raceForVariabl
e
=
TemporaryBindingTrace
.
create
(
context
.
trace
);
OverloadResolutionResults
<
VariableDescriptor
>
resolutionResult
=
context
.
replaceBindingTrace
(
t
raceForVariabl
e
).
resolveSimpleProperty
(
receiver
,
callOperationNode
,
nameExpression
);
if
(!
resolutionResult
.
isNothing
())
{
t
emporaryTrac
e
.
commit
();
t
raceForVariabl
e
.
commit
();
checkSuper
(
receiver
,
resolutionResult
,
context
.
trace
,
nameExpression
);
result
[
0
]
=
true
;
return
resolutionResult
.
isSingleResult
()
?
resolutionResult
.
getResultingDescriptor
().
getReturnType
()
:
null
;
...
...
@@ -625,8 +625,10 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
ExpressionTypingContext
newContext
=
receiver
.
exists
()
?
context
.
replaceScope
(
receiver
.
getType
().
getMemberScope
())
:
context
;
JetType
jetType
=
lookupNamespaceOrClassObject
(
nameExpression
,
nameExpression
.
getReferencedNameAsName
(),
newContext
);
TemporaryBindingTrace
traceForNamespaceOrClassObject
=
TemporaryBindingTrace
.
create
(
context
.
trace
);
JetType
jetType
=
lookupNamespaceOrClassObject
(
nameExpression
,
nameExpression
.
getReferencedNameAsName
(),
newContext
.
replaceBindingTrace
(
traceForNamespaceOrClassObject
));
if
(
jetType
!=
null
)
{
traceForNamespaceOrClassObject
.
commit
();
// Uncommitted changes in temp context
context
.
trace
.
record
(
RESOLUTION_SCOPE
,
nameExpression
,
context
.
scope
);
...
...
compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2125.jet
0 → 100644
浏览文件 @
7dab62ec
//
KT
-
2125
Inconsistent
error
message
on
UNSAFE_CALL
package
e
fun
main
()
{
val
<
!UNUSED_VARIABLE!>compareTo<!> = 1
val
s
:
String
?
=
null
s
<
!UNSAFE_CALL!>.<!>compareTo("")
val
<
!UNUSED_VARIABLE!>bar<!> = 2
s
.<
!UNRESOLVED_REFERENCE!>bar<!>()
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录