Make sure lateinit top-level properties work in JVM BE
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
|||||||
|
// WITH_REFLECT
|
||||||
|
// IGNORE_BACKEND: JS, NATIVE
|
||||||
|
// FILE: lateinit.kt
|
||||||
|
private lateinit var s: String
|
||||||
|
|
||||||
|
object C {
|
||||||
|
fun setS(value: String) { s = value }
|
||||||
|
fun getS() = s
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: test.kt
|
||||||
|
import kotlin.UninitializedPropertyAccessException
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
var str2: String = ""
|
||||||
|
try {
|
||||||
|
str2 = C.getS()
|
||||||
|
return "Should throw an exception"
|
||||||
|
}
|
||||||
|
catch (e: UninitializedPropertyAccessException) {
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
catch (e: Throwable) {
|
||||||
|
return "Unexpected exception: ${e::class.qualifiedName}"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
// FILE: lateinit.kt
|
||||||
|
private lateinit var s: String
|
||||||
|
|
||||||
|
object C {
|
||||||
|
fun setS(value: String) { s = value }
|
||||||
|
fun getS() = s
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: test.kt
|
||||||
|
fun box(): String {
|
||||||
|
C.setS("OK")
|
||||||
|
return C.getS()
|
||||||
|
}
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
lateinit var ok: String
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
run {
|
||||||
|
ok = "OK"
|
||||||
|
}
|
||||||
|
return ok
|
||||||
|
}
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
// WITH_REFLECT
|
||||||
|
// IGNORE_BACKEND: JS, NATIVE
|
||||||
|
|
||||||
|
import kotlin.UninitializedPropertyAccessException
|
||||||
|
|
||||||
|
lateinit var str: String
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
var i: Int = 0
|
||||||
|
try {
|
||||||
|
i = str.length
|
||||||
|
return "Should throw an exception"
|
||||||
|
}
|
||||||
|
catch (e: UninitializedPropertyAccessException) {
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
catch (e: Throwable) {
|
||||||
|
return "Unexpected exception: ${e::class.qualifiedName}"
|
||||||
|
}
|
||||||
|
}
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
// WITH_REFLECT
|
||||||
|
// IGNORE_BACKEND: JS, NATIVE
|
||||||
|
|
||||||
|
import kotlin.UninitializedPropertyAccessException
|
||||||
|
|
||||||
|
lateinit var str: String
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
var str2: String = ""
|
||||||
|
try {
|
||||||
|
str2 = str
|
||||||
|
return "Should throw an exception"
|
||||||
|
}
|
||||||
|
catch (e: UninitializedPropertyAccessException) {
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
catch (e: Throwable) {
|
||||||
|
return "Unexpected exception: ${e::class.qualifiedName}"
|
||||||
|
}
|
||||||
|
}
|
||||||
+39
@@ -13419,6 +13419,45 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class TopLevel extends AbstractIrBlackBoxCodegenTest {
|
||||||
|
@TestMetadata("accessorException.kt")
|
||||||
|
public void testAccessorException() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel/accessorException.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("accessorForTopLevelLateinit.kt")
|
||||||
|
public void testAccessorForTopLevelLateinit() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel/accessorForTopLevelLateinit.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInTopLevel() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/properties/lateinit/topLevel"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("topLevelLateinit.kt")
|
||||||
|
public void testTopLevelLateinit() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel/topLevelLateinit.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("uninitializedMemberAccess.kt")
|
||||||
|
public void testUninitializedMemberAccess() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel/uninitializedMemberAccess.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("uninitializedRead.kt")
|
||||||
|
public void testUninitializedRead() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel/uninitializedRead.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13419,6 +13419,45 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class TopLevel extends AbstractBlackBoxCodegenTest {
|
||||||
|
@TestMetadata("accessorException.kt")
|
||||||
|
public void testAccessorException() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel/accessorException.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("accessorForTopLevelLateinit.kt")
|
||||||
|
public void testAccessorForTopLevelLateinit() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel/accessorForTopLevelLateinit.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInTopLevel() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/properties/lateinit/topLevel"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("topLevelLateinit.kt")
|
||||||
|
public void testTopLevelLateinit() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel/topLevelLateinit.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("uninitializedMemberAccess.kt")
|
||||||
|
public void testUninitializedMemberAccess() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel/uninitializedMemberAccess.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("uninitializedRead.kt")
|
||||||
|
public void testUninitializedRead() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel/uninitializedRead.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13419,6 +13419,45 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class TopLevel extends AbstractLightAnalysisModeTest {
|
||||||
|
@TestMetadata("accessorException.kt")
|
||||||
|
public void testAccessorException() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel/accessorException.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("accessorForTopLevelLateinit.kt")
|
||||||
|
public void testAccessorForTopLevelLateinit() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel/accessorForTopLevelLateinit.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInTopLevel() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/properties/lateinit/topLevel"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("topLevelLateinit.kt")
|
||||||
|
public void testTopLevelLateinit() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel/topLevelLateinit.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("uninitializedMemberAccess.kt")
|
||||||
|
public void testUninitializedMemberAccess() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel/uninitializedMemberAccess.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("uninitializedRead.kt")
|
||||||
|
public void testUninitializedRead() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel/uninitializedRead.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+57
@@ -15069,6 +15069,63 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
|
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class TopLevel extends AbstractJsCodegenBoxTest {
|
||||||
|
@TestMetadata("accessorException.kt")
|
||||||
|
public void testAccessorException() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel/accessorException.kt");
|
||||||
|
try {
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
catch (Throwable ignore) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("accessorForTopLevelLateinit.kt")
|
||||||
|
public void testAccessorForTopLevelLateinit() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel/accessorForTopLevelLateinit.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInTopLevel() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/properties/lateinit/topLevel"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("topLevelLateinit.kt")
|
||||||
|
public void testTopLevelLateinit() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel/topLevelLateinit.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("uninitializedMemberAccess.kt")
|
||||||
|
public void testUninitializedMemberAccess() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel/uninitializedMemberAccess.kt");
|
||||||
|
try {
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
catch (Throwable ignore) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("uninitializedRead.kt")
|
||||||
|
public void testUninitializedRead() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/properties/lateinit/topLevel/uninitializedRead.kt");
|
||||||
|
try {
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
catch (Throwable ignore) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user