From 690efbb39a2e4f02cae84b76b5ae610f1675a911 Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Mon, 28 Nov 2011 17:06:22 +0400 Subject: [PATCH] KT-552 For variable unresolved if loop body is not block === for(index in 0..9) x[index] = index.byt // <-- index is inresolved here === --- .../types/expressions/ControlStructureTypingVisitor.java | 3 ++- .../quick/control/ForWithoutBraces.jet | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/checkerWithErrorTypes/quick/control/ForWithoutBraces.jet diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java index d260b7ef9e3..a9a48119c7b 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java @@ -216,7 +216,8 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { JetExpression body = expression.getBody(); if (body != null) { - facade.getType(body, context.replaceScope(loopScope)); + ExpressionTypingInternals blockLevelVisitor = ExpressionTypingVisitorDispatcher.createForBlock(loopScope); + blockLevelVisitor.getType(body, context.replaceScope(loopScope)); } return DataFlowUtils.checkType(JetStandardClasses.getUnitType(), expression, contextWithExpectedType); diff --git a/compiler/testData/checkerWithErrorTypes/quick/control/ForWithoutBraces.jet b/compiler/testData/checkerWithErrorTypes/quick/control/ForWithoutBraces.jet new file mode 100644 index 00000000000..d79dd7e77e0 --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/control/ForWithoutBraces.jet @@ -0,0 +1,8 @@ +// http://youtrack.jetbrains.net/issue/KT-552 +// KT-552 For variable unresolved if loop body is not block + +fun ff() { + var i = 1 + for (j in 1..10) + i += j +}