Partial body resolve: corrected it for explicit function type but unfortunately it does not work for non-explicit type yet

This commit is contained in:
Valentin Kipyatkov
2014-11-21 12:32:26 +03:00
parent 058af69078
commit cc84e9682b
5 changed files with 36 additions and 3 deletions
@@ -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)
}
@@ -0,0 +1,6 @@
fun foo() = run {
print("a")
val v = 1
print(<caret>v)
"x"
}
@@ -0,0 +1,8 @@
Resolve target: val v: kotlin.Int
----------------------------------------------
fun foo(): String = run {
// STATEMENT DELETED: print("a")
val v = 1
print(<caret>v)
"x"
}
@@ -0,0 +1,6 @@
fun foo(): String = run {
print("a")
val v = 1
print(<caret>v)
"x"
}
@@ -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");