Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
84f32c99
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,发现更多精彩内容 >>
提交
84f32c99
编写于
4月 17, 2012
作者:
S
Svetlana Isakova
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
incomplete assignment bug from EA fixed
上级
091d8176
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
3 deletion
+36
-3
compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorForStatements.java
...pes/expressions/ExpressionTypingVisitorForStatements.java
+6
-3
compiler/testData/diagnostics/tests/incompleteCode/incompleteAssignment.jet
...diagnostics/tests/incompleteCode/incompleteAssignment.jet
+30
-0
未找到文件。
compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorForStatements.java
浏览文件 @
84f32c99
...
...
@@ -169,6 +169,9 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
}
protected
JetType
visitAssignmentOperation
(
JetBinaryExpression
expression
,
ExpressionTypingContext
contextWithExpectedType
)
{
JetExpression
right
=
expression
.
getRight
();
if
(
right
==
null
)
return
null
;
//There is a temporary binding trace for an opportunity to resolve set method for array if needed (the initial trace should be used there)
TemporaryBindingTrace
temporaryBindingTrace
=
TemporaryBindingTrace
.
create
(
contextWithExpectedType
.
trace
);
ExpressionTypingContext
context
=
contextWithExpectedType
.
replaceExpectedType
(
TypeUtils
.
NO_EXPECTED_TYPE
).
replaceExpectedReturnType
(
TypeUtils
.
NO_EXPECTED_TYPE
).
replaceBindingTrace
(
temporaryBindingTrace
);
...
...
@@ -180,7 +183,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
JetType
leftType
=
facade
.
getType
(
left
,
context
);
if
(
leftType
==
null
)
{
facade
.
getType
(
expression
.
getRight
()
,
context
);
facade
.
getType
(
right
,
context
);
context
.
trace
.
report
(
UNRESOLVED_REFERENCE
.
on
(
operationSign
));
temporaryBindingTrace
.
commit
();
return
null
;
...
...
@@ -208,7 +211,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
for
(
ResolvedCall
<?
extends
FunctionDescriptor
>
call
:
ambiguityResolutionResults
.
getResultingCalls
())
{
descriptors
.
add
(
call
.
getResultingDescriptor
());
}
facade
.
getType
(
expression
.
getRight
()
,
context
);
facade
.
getType
(
right
,
context
);
context
.
trace
.
record
(
AMBIGUOUS_REFERENCE_TARGET
,
operationSign
,
descriptors
);
}
else
if
(
assignmentOperationType
!=
null
)
{
...
...
@@ -222,7 +225,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
context
.
trace
.
record
(
VARIABLE_REASSIGNMENT
,
expression
);
if
(
left
instanceof
JetArrayAccessExpression
)
{
ExpressionTypingContext
contextForResolve
=
context
.
replaceScope
(
scope
).
replaceBindingTrace
(
TemporaryBindingTrace
.
create
(
contextWithExpectedType
.
trace
));
basic
.
resolveArrayAccessSetMethod
((
JetArrayAccessExpression
)
left
,
expression
.
getRight
()
,
contextForResolve
,
context
.
trace
);
basic
.
resolveArrayAccessSetMethod
((
JetArrayAccessExpression
)
left
,
right
,
contextForResolve
,
context
.
trace
);
}
}
basic
.
checkLValue
(
context
.
trace
,
expression
.
getLeft
());
...
...
compiler/testData/diagnostics/tests/incompleteCode/incompleteAssignment.jet
0 → 100644
浏览文件 @
84f32c99
package
sum
import
java
.
util
.*
fun
sum
(
a
:
IntArray
)
:
Int
{
//
Write
your
solution
here
<
!UNRESOLVED_REFERENCE!>res<!> = 0
for
(
e
in
a
)
res
+=<
!SYNTAX!><!>
<
!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
fun
main
(
args
:
Array
<
String
>)
{
test
(
0
)
test
(
1
,
1
)
test
(-
1
,
-
1
,
0
)
test
(
6
,
1
,
2
,
3
)
test
(
6
,
1
,
1
,
1
,
1
,
1
,
1
)
}
//
HELPER
FUNCTIONS
fun
test
(
expectedSum
:
Int
,
vararg
data
:
Int
)
{
val
actualSum
=
sum
(
data
)
assertEquals
(
actualSum
,
expectedSum
,
"
\n
data = ${Arrays.toString(data)}
\n
"
+
"sum(data) = ${actualSum}, but must be $expectedSum "
)
}
fun
assertEquals
<
T
>(
actual
:
T
?,
expected
:
T
?,
message
:
Any
?
=
null
)
{
if
(
actual
!= expected) {
if
(
message
==
null
)
throw
AssertionError
()
else
throw
AssertionError
(
message
)
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录