diff --git a/idea/testData/resolve/partialBodyResolve/For1.dump b/idea/testData/resolve/partialBodyResolve/For1.dump new file mode 100644 index 00000000000..c4ff762235a --- /dev/null +++ b/idea/testData/resolve/partialBodyResolve/For1.dump @@ -0,0 +1,7 @@ +Resolve target: null +---------------------------------------------- +fun foo(p: Any?, c: Collection) { + // STATEMENT DELETED: for (e in c) { print(p!!) } + + xxx +} diff --git a/idea/testData/resolve/partialBodyResolve/For1.kt b/idea/testData/resolve/partialBodyResolve/For1.kt new file mode 100644 index 00000000000..8d4d09f4879 --- /dev/null +++ b/idea/testData/resolve/partialBodyResolve/For1.kt @@ -0,0 +1,7 @@ +fun foo(p: Any?, c: Collection) { + for (e in c) { + print(p!!) + } + + xxx +} \ No newline at end of file diff --git a/idea/testData/resolve/partialBodyResolve/For.dump b/idea/testData/resolve/partialBodyResolve/For2.dump similarity index 100% rename from idea/testData/resolve/partialBodyResolve/For.dump rename to idea/testData/resolve/partialBodyResolve/For2.dump diff --git a/idea/testData/resolve/partialBodyResolve/For.kt b/idea/testData/resolve/partialBodyResolve/For2.kt similarity index 100% rename from idea/testData/resolve/partialBodyResolve/For.kt rename to idea/testData/resolve/partialBodyResolve/For2.kt diff --git a/idea/testData/resolve/partialBodyResolve/IfNullAlwaysExits.dump b/idea/testData/resolve/partialBodyResolve/IfNullAlwaysExits.dump new file mode 100644 index 00000000000..f5226def9c8 --- /dev/null +++ b/idea/testData/resolve/partialBodyResolve/IfNullAlwaysExits.dump @@ -0,0 +1,31 @@ +Resolve target: value-parameter val p: kotlin.String? smart-cast to kotlin.String +---------------------------------------------- +fun foo(p: String?, x: Boolean, y: Boolean, z: Boolean, t: Boolean) { + if (p == null) { + if (x) { + // STATEMENT DELETED: print("x") + error("error") + } + else if (y) { + // STATEMENT DELETED: print("y") + if (z) { + // STATEMENT DELETED: print("z") + return + } + else { + throw Exception() + } + } + else { + if (t) { + // STATEMENT DELETED: print("t") + return + } + else { + return + } + } + } + + p.length +} diff --git a/idea/testData/resolve/partialBodyResolve/IfNullAlwaysExits.kt b/idea/testData/resolve/partialBodyResolve/IfNullAlwaysExits.kt new file mode 100644 index 00000000000..87ccccb6166 --- /dev/null +++ b/idea/testData/resolve/partialBodyResolve/IfNullAlwaysExits.kt @@ -0,0 +1,29 @@ +fun foo(p: String?, x: Boolean, y: Boolean, z: Boolean, t: Boolean) { + if (p == null) { + if (x) { + print("x") + error("error") + } + else if (y) { + print("y") + if (z) { + print("z") + return + } + else { + throw Exception() + } + } + else { + if (t) { + print("t") + return + } + else { + return + } + } + } + + p.length +} \ No newline at end of file diff --git a/idea/testData/resolve/partialBodyResolve/LabeledBreak.dump b/idea/testData/resolve/partialBodyResolve/LabeledBreak.dump new file mode 100644 index 00000000000..4e8e3545de0 --- /dev/null +++ b/idea/testData/resolve/partialBodyResolve/LabeledBreak.dump @@ -0,0 +1,16 @@ +Resolve target: val x: kotlin.Any? +---------------------------------------------- +fun foo() { + @MainLoop + for (i in 1..10) { + val x = take() + if (x == null) { + while (true) { + break@MainLoop + } + } + x.hashCode() + } +} + +fun take(): Any? = null diff --git a/idea/testData/resolve/partialBodyResolve/LabeledBreak.kt b/idea/testData/resolve/partialBodyResolve/LabeledBreak.kt new file mode 100644 index 00000000000..f34bab64fab --- /dev/null +++ b/idea/testData/resolve/partialBodyResolve/LabeledBreak.kt @@ -0,0 +1,14 @@ +fun foo() { + @MainLoop + for (i in 1..10) { + val x = take() + if (x == null) { + while (true) { + break@MainLoop + } + } + x.hashCode() + } +} + +fun take(): Any? = null diff --git a/idea/testData/resolve/partialBodyResolve/LabeledContinue.dump b/idea/testData/resolve/partialBodyResolve/LabeledContinue.dump new file mode 100644 index 00000000000..40294362343 --- /dev/null +++ b/idea/testData/resolve/partialBodyResolve/LabeledContinue.dump @@ -0,0 +1,16 @@ +Resolve target: val x: kotlin.Any? +---------------------------------------------- +fun foo() { + @MainLoop + for (i in 1..10) { + val x = take() + if (x == null) { + while (true) { + continue@MainLoop + } + } + x.hashCode() + } +} + +fun take(): Any? = null diff --git a/idea/testData/resolve/partialBodyResolve/LabeledContinue.kt b/idea/testData/resolve/partialBodyResolve/LabeledContinue.kt new file mode 100644 index 00000000000..d90e455846f --- /dev/null +++ b/idea/testData/resolve/partialBodyResolve/LabeledContinue.kt @@ -0,0 +1,14 @@ +fun foo() { + @MainLoop + for (i in 1..10) { + val x = take() + if (x == null) { + while (true) { + continue@MainLoop + } + } + x.hashCode() + } +} + +fun take(): Any? = null diff --git a/idea/testData/resolve/partialBodyResolve/OutOfBodyResolve.dump b/idea/testData/resolve/partialBodyResolve/OutOfBodyResolve.dump new file mode 100644 index 00000000000..f80993a870b --- /dev/null +++ b/idea/testData/resolve/partialBodyResolve/OutOfBodyResolve.dump @@ -0,0 +1,8 @@ +Resolve target: val v: kotlin.String +---------------------------------------------- +val v = "" + +fun foo(s: String = v) { + // STATEMENT DELETED: val local = 1 + // STATEMENT DELETED: print("foo" + local) +} diff --git a/idea/testData/resolve/partialBodyResolve/OutOfBodyResolve.kt b/idea/testData/resolve/partialBodyResolve/OutOfBodyResolve.kt new file mode 100644 index 00000000000..c1aebba0a97 --- /dev/null +++ b/idea/testData/resolve/partialBodyResolve/OutOfBodyResolve.kt @@ -0,0 +1,6 @@ +val v = "" + +fun foo(s: String = v) { + val local = 1 + print("foo" + local) +} \ 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 53610227506..962de08f431 100644 --- a/idea/tests/org/jetbrains/jet/resolve/PartialBodyResolveTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/resolve/PartialBodyResolveTestGenerated.java @@ -72,9 +72,15 @@ public class PartialBodyResolveTestGenerated extends AbstractPartialBodyResolveT doTest(fileName); } - @TestMetadata("For.kt") - public void testFor() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/For.kt"); + @TestMetadata("For1.kt") + public void testFor1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/For1.kt"); + doTest(fileName); + } + + @TestMetadata("For2.kt") + public void testFor2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/For2.kt"); doTest(fileName); } @@ -156,6 +162,12 @@ public class PartialBodyResolveTestGenerated extends AbstractPartialBodyResolveT doTest(fileName); } + @TestMetadata("IfNullAlwaysExits.kt") + public void testIfNullAlwaysExits() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/IfNullAlwaysExits.kt"); + doTest(fileName); + } + @TestMetadata("IfNullBreak.kt") public void testIfNullBreak() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/IfNullBreak.kt"); @@ -234,6 +246,18 @@ public class PartialBodyResolveTestGenerated extends AbstractPartialBodyResolveT doTest(fileName); } + @TestMetadata("LabeledBreak.kt") + public void testLabeledBreak() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/LabeledBreak.kt"); + doTest(fileName); + } + + @TestMetadata("LabeledContinue.kt") + public void testLabeledContinue() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/LabeledContinue.kt"); + doTest(fileName); + } + @TestMetadata("Lambda.kt") public void testLambda() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/Lambda.kt"); @@ -270,6 +294,12 @@ public class PartialBodyResolveTestGenerated extends AbstractPartialBodyResolveT doTest(fileName); } + @TestMetadata("OutOfBodyResolve.kt") + public void testOutOfBodyResolve() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/OutOfBodyResolve.kt"); + doTest(fileName); + } + @TestMetadata("ReturnLambda.kt") public void testReturnLambda() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/ReturnLambda.kt");