KT-11960: add test for case of instantiating inner class of a local class
This commit is contained in:
@@ -187,4 +187,8 @@ public final class ClosureTest extends SingleFileTranslationTest {
|
||||
public void testClosureThisInLambdaInsideObject() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testLambdaInLocalFun() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
}
|
||||
|
||||
+18
@@ -31,6 +31,12 @@ import java.util.regex.Pattern;
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class LocalClassesTestGenerated extends AbstractLocalClassesTest {
|
||||
@TestMetadata("ownClosureOfInnerLocalClass.kt")
|
||||
public void ignoredOwnClosureOfInnerLocalClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/localClasses/ownClosureOfInnerLocalClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInLocalClasses() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/localClasses"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
@@ -47,6 +53,18 @@ public class LocalClassesTestGenerated extends AbstractLocalClassesTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("closureOfInnerLocalClass.kt")
|
||||
public void testClosureOfInnerLocalClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/localClasses/closureOfInnerLocalClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("closureOfLambdaInLocalClass.kt")
|
||||
public void testClosureOfLambdaInLocalClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/localClasses/closureOfLambdaInLocalClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("closureWithSelfInstantiation.kt")
|
||||
public void testClosureWithSelfInstantiation() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/localClasses/closureWithSelfInstantiation.kt");
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package foo
|
||||
|
||||
fun box(): String {
|
||||
var log = ""
|
||||
|
||||
var s: Any? = null
|
||||
for (t in arrayOf("1", "2", "3")) {
|
||||
fun foo() = {
|
||||
fun q() = { t }
|
||||
q()
|
||||
}
|
||||
|
||||
if (s == null) {
|
||||
s = foo()
|
||||
}
|
||||
|
||||
log += (s as (() -> (() -> String)))()()
|
||||
}
|
||||
|
||||
if (log != "111") return "fail1: ${log}"
|
||||
|
||||
s = null
|
||||
log = ""
|
||||
for (t in arrayOf("1", "2", "3")) {
|
||||
fun foo() = {
|
||||
val y = t
|
||||
fun q() = { y }
|
||||
q()
|
||||
}
|
||||
|
||||
if (s == null) {
|
||||
s = foo()
|
||||
}
|
||||
|
||||
log += (s as (() -> (() -> String)))()()
|
||||
}
|
||||
|
||||
if (log != "111") return "fail2: ${log}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user