Partial body resolve: added a test to fail if smart-casts will become too clever
This commit is contained in:
@@ -175,7 +175,6 @@ class PartialBodyResolveFilter(elementToResolve: JetElement, private val body: J
|
|||||||
override fun visitWhileExpression(expression: JetWhileExpression) {
|
override fun visitWhileExpression(expression: JetWhileExpression) {
|
||||||
val condition = expression.getCondition()
|
val condition = expression.getCondition()
|
||||||
// we need to enter the body only for "while(true)"
|
// we need to enter the body only for "while(true)"
|
||||||
//TODO: what about e.g. "1 == 1"
|
|
||||||
if (condition.isTrueConstant()) {
|
if (condition.isTrueConstant()) {
|
||||||
expression.acceptChildren(this)
|
expression.acceptChildren(this)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
Resolve target: value-parameter val p: kotlin.Any?
|
||||||
|
Skipped statements:
|
||||||
|
while(2 * 2 == 4) { print(p!!) if (x()) break }
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// this test will fail if control flow analysis will start to produce smart-casts after "while(2 * 2 == 4)"
|
||||||
|
|
||||||
|
fun x(): Boolean{}
|
||||||
|
|
||||||
|
fun foo(p: Any?) {
|
||||||
|
while(2 * 2 == 4) {
|
||||||
|
print(p!!)
|
||||||
|
if (x()) break
|
||||||
|
}
|
||||||
|
|
||||||
|
<caret>p.hashCode()
|
||||||
|
}
|
||||||
@@ -19,7 +19,6 @@ package org.jetbrains.jet.resolve;
|
|||||||
import com.intellij.testFramework.TestDataPath;
|
import com.intellij.testFramework.TestDataPath;
|
||||||
import org.jetbrains.jet.JUnit3RunnerWithInners;
|
import org.jetbrains.jet.JUnit3RunnerWithInners;
|
||||||
import org.jetbrains.jet.JetTestUtils;
|
import org.jetbrains.jet.JetTestUtils;
|
||||||
import org.jetbrains.jet.test.InnerTestClasses;
|
|
||||||
import org.jetbrains.jet.test.TestMetadata;
|
import org.jetbrains.jet.test.TestMetadata;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@@ -227,4 +226,10 @@ public class PartialBodyResolveTestGenerated extends AbstractPartialBodyResolveT
|
|||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/WhileTrue.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/WhileTrue.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WhileTrueCondition.kt")
|
||||||
|
public void testWhileTrueCondition() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/WhileTrueCondition.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user