diff --git a/idea/ide-common/src/org/jetbrains/jet/lang/resolve/lazy/PartialBodyResolveFilter.kt b/idea/ide-common/src/org/jetbrains/jet/lang/resolve/lazy/PartialBodyResolveFilter.kt index 38fb90165fe..cfef78cccfc 100644 --- a/idea/ide-common/src/org/jetbrains/jet/lang/resolve/lazy/PartialBodyResolveFilter.kt +++ b/idea/ide-common/src/org/jetbrains/jet/lang/resolve/lazy/PartialBodyResolveFilter.kt @@ -68,6 +68,10 @@ class PartialBodyResolveFilter( //TODO: do..while is special case private fun processBlock(block: JetBlockExpression): NameFilter { + if (isValueNeeded(block)) { + block.lastStatement()?.let { statementTree.mark(it, MarkLevel.NEED_REFERENCE_RESOLVE) } + } + val nameFilter = NameFilter() if (!statementTree.hasMarks(block, MarkLevel.NEED_REFERENCE_RESOLVE)) return nameFilter @@ -117,9 +121,6 @@ class PartialBodyResolveFilter( val level = statementTree.statementMark(statement) if (level > MarkLevel.RESOLVE_STATEMENT) { for (nestedBlock in statementTree.blocks(statement)) { - if (isValueNeeded(nestedBlock)) { - nestedBlock.lastStatement()?.let { statementTree.mark(it, MarkLevel.NEED_REFERENCE_RESOLVE) } - } val childFilter = processBlock(nestedBlock) nameFilter.addNames(childFilter) } diff --git a/idea/testData/resolve/partialBodyResolve/ExpressionBody.kt.todo b/idea/testData/resolve/partialBodyResolve/ExpressionBody.kt.todo new file mode 100644 index 00000000000..81aab81bc43 --- /dev/null +++ b/idea/testData/resolve/partialBodyResolve/ExpressionBody.kt.todo @@ -0,0 +1,6 @@ +fun foo() = run { + print("a") + val v = 1 + print(v) + "x" +} \ No newline at end of file diff --git a/idea/testData/resolve/partialBodyResolve/ExpressionBodyExplicitType.dump b/idea/testData/resolve/partialBodyResolve/ExpressionBodyExplicitType.dump new file mode 100644 index 00000000000..94e4f2c0be2 --- /dev/null +++ b/idea/testData/resolve/partialBodyResolve/ExpressionBodyExplicitType.dump @@ -0,0 +1,8 @@ +Resolve target: val v: kotlin.Int +---------------------------------------------- +fun foo(): String = run { + // STATEMENT DELETED: print("a") + val v = 1 + print(v) + "x" +} \ No newline at end of file diff --git a/idea/testData/resolve/partialBodyResolve/ExpressionBodyExplicitType.kt b/idea/testData/resolve/partialBodyResolve/ExpressionBodyExplicitType.kt new file mode 100644 index 00000000000..998df860e1e --- /dev/null +++ b/idea/testData/resolve/partialBodyResolve/ExpressionBodyExplicitType.kt @@ -0,0 +1,6 @@ +fun foo(): String = run { + print("a") + val v = 1 + print(v) + "x" +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/resolve/PartialBodyResolveTestGenerated.java b/idea/tests/org/jetbrains/jet/resolve/PartialBodyResolveTestGenerated.java index 962de08f431..136d31a621f 100644 --- a/idea/tests/org/jetbrains/jet/resolve/PartialBodyResolveTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/resolve/PartialBodyResolveTestGenerated.java @@ -72,6 +72,18 @@ public class PartialBodyResolveTestGenerated extends AbstractPartialBodyResolveT doTest(fileName); } + @TestMetadata("ExpressionBody.kt") + public void testExpressionBody() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/ExpressionBody.kt"); + doTest(fileName); + } + + @TestMetadata("ExpressionBodyExplicitType.kt") + public void testExpressionBodyExplicitType() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/ExpressionBodyExplicitType.kt"); + doTest(fileName); + } + @TestMetadata("For1.kt") public void testFor1() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/For1.kt");