Add black box tests for objects inheritance problem (KT-25289)

This commit is contained in:
victor.petukhov
2018-12-14 13:45:15 +03:00
parent fc381e25c8
commit 8c0ad321e2
42 changed files with 680 additions and 2 deletions
+3 -2
View File
@@ -28,8 +28,9 @@ val remoteRunTests by task<Test> {
val packagePrefix = "org.jetbrains.kotlin."
val includeTests = setOf(
"checkers.DiagnosticsTestSpecGenerated\$NotLinked\$Contracts*",
"checkers.DiagnosticsTestSpecGenerated\$NotLinked\$Annotations*",
"codegen.BlackBoxCodegenTestSpecGenerated\$NotLinked\$Annotations*"
"checkers.DiagnosticsTestSpecGenerated\$NotLinked\$Annotations\$Type_annotations*",
"codegen.BlackBoxCodegenTestSpecGenerated\$NotLinked\$Annotations\$Type_annotations*",
"codegen.BlackBoxCodegenTestSpecGenerated\$NotLinked\$Objects\$Inheritance*"
)
workingDir = rootDir
@@ -0,0 +1,2 @@
java.lang.ExceptionInInitializerError
_1Kt.box(1.kt:18)
@@ -0,0 +1,21 @@
/*
* KOTLIN CODEGEN BOX NOT LINKED SPEC TEST (NEGATIVE)
*
* SECTIONS: objects, inheritance
* NUMBER: 1
* DESCRIPTION: Access to class members in the super constructor call of an object.
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25289
*/
open class Bar(val x: Int)
open class Foo {
companion object : Bar(Foo.x)
}
fun box(): String? {
if (Foo() == null) return null
return "OK"
}
@@ -0,0 +1,2 @@
java.lang.ExceptionInInitializerError
Foo$A.<init>(10.kt:12)
@@ -0,0 +1,20 @@
/*
* KOTLIN CODEGEN BOX NOT LINKED SPEC TEST (NEGATIVE)
*
* SECTIONS: objects, inheritance
* NUMBER: 10
* DESCRIPTION: Access to class members in the super constructor call of an object.
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25289
*/
open class Foo(a: Any) {
object A : Foo(B)
object B : Foo(A)
}
fun box(): String? {
if (Foo.A == null) return null
return "OK"
}
@@ -0,0 +1,2 @@
java.lang.ExceptionInInitializerError
_11Kt.box(11.kt:20)
@@ -0,0 +1,23 @@
/*
* KOTLIN CODEGEN BOX NOT LINKED SPEC TEST (NEGATIVE)
*
* SECTIONS: objects, inheritance
* NUMBER: 11
* DESCRIPTION: Access to class members in the super constructor call of an object.
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25289
*/
object MyObject : Foo(prop)
open class Foo(val x: MyObject) {
companion object {
val prop = MyObject
}
}
fun box(): String? {
if (MyObject == null) return null
return "OK"
}
@@ -0,0 +1,2 @@
java.lang.IllegalArgumentException: Parameter specified as non-null is null: method Foo.<init>, parameter x
Foo.<init>(12.kt)
@@ -0,0 +1,21 @@
/*
* KOTLIN CODEGEN BOX NOT LINKED SPEC TEST (NEGATIVE)
*
* SECTIONS: objects, inheritance
* NUMBER: 12
* DESCRIPTION: Access to class members in the super constructor call of an object.
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25289
*/
val prop = MyObject
object MyObject : Foo(prop)
open class Foo(val x: MyObject)
fun box(): String? {
if (MyObject == null) return null
return "OK"
}
@@ -0,0 +1,15 @@
java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
Foo$Companion.<init>()V @2: checkcast
Reason:
Type uninitializedThis (current frame, stack[1]) is not assignable to 'java/lang/Object'
Current Frame:
bci: @2
flags: { flagThisUninit }
locals: { uninitializedThis }
stack: { uninitializedThis, uninitializedThis }
Bytecode:
0x0000000: 2a2a c000 02b6 000a b700 0db1
Foo.<clinit>(13.kt)
@@ -0,0 +1,19 @@
/*
* KOTLIN CODEGEN BOX NOT LINKED SPEC TEST (NEGATIVE)
*
* SECTIONS: objects, inheritance
* NUMBER: 13
* DESCRIPTION: Access to class members in the super constructor call of an object.
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25289
*/
open class Foo(val prop: Int) {
companion object : Foo(prop)
}
fun box(): String? {
if (Foo(42) == null) return null
return "OK"
}
@@ -0,0 +1,2 @@
java.lang.ExceptionInInitializerError
_14Kt.box(14.kt:16)
@@ -0,0 +1,19 @@
/*
* KOTLIN CODEGEN BOX NOT LINKED SPEC TEST (NEGATIVE)
*
* SECTIONS: objects, inheritance
* NUMBER: 14
* DESCRIPTION: Access to class members in the super constructor call of an object.
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25289
*/
open class Foo(val prop: Int) {
companion object MyCompanion : Foo(Foo.prop)
}
fun box(): String? {
if (Foo(42) == null) return null
return "OK"
}
@@ -0,0 +1,2 @@
java.lang.ExceptionInInitializerError
_15Kt.box(15.kt:16)
@@ -0,0 +1,19 @@
/*
* KOTLIN CODEGEN BOX NOT LINKED SPEC TEST (NEGATIVE)
*
* SECTIONS: objects, inheritance
* NUMBER: 15
* DESCRIPTION: Access to class members in the super constructor call of an object.
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25289
*/
open class Foo(val prop: Int) {
object MyObject : Foo(MyObject.prop)
}
fun box(): String? {
if (Foo.MyObject == null) return null
return "OK"
}
@@ -0,0 +1,15 @@
java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
Foo$Companion.<init>()V @2: checkcast
Reason:
Type uninitializedThis (current frame, stack[1]) is not assignable to 'java/lang/Object'
Current Frame:
bci: @2
flags: { flagThisUninit }
locals: { uninitializedThis }
stack: { uninitializedThis, uninitializedThis }
Bytecode:
0x0000000: 2a2a c000 02b6 000a b700 0db1
Foo.<clinit>(16.kt)
@@ -0,0 +1,19 @@
/*
* KOTLIN CODEGEN BOX NOT LINKED SPEC TEST (NEGATIVE)
*
* SECTIONS: objects, inheritance
* NUMBER: 16
* DESCRIPTION: Access to class members in the super constructor call of an object.
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25289
*/
open class Foo(val prop: Int) {
companion object : Foo(prop)
}
fun box(): String? {
if (Foo(42) == null) return null
return "OK"
}
@@ -0,0 +1,15 @@
java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
Foo$Companion.<init>()V @2: checkcast
Reason:
Type uninitializedThis (current frame, stack[1]) is not assignable to 'java/lang/Object'
Current Frame:
bci: @2
flags: { flagThisUninit }
locals: { uninitializedThis }
stack: { uninitializedThis, uninitializedThis }
Bytecode:
0x0000000: 2a2a c000 02b6 000a b700 0db1
Foo.<clinit>(17.kt)
@@ -0,0 +1,19 @@
/*
* KOTLIN CODEGEN BOX NOT LINKED SPEC TEST (NEGATIVE)
*
* SECTIONS: objects, inheritance
* NUMBER: 17
* DESCRIPTION: Access to class members in the super constructor call of an object.
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25289
*/
open class Foo(val prop: Int) {
companion object : Foo(this.prop)
}
fun box(): String? {
if (Foo(42) == null) return null
return "OK"
}
@@ -0,0 +1,2 @@
java.lang.ExceptionInInitializerError
_18Kt.box(18.kt:16)
@@ -0,0 +1,19 @@
/*
* KOTLIN CODEGEN BOX NOT LINKED SPEC TEST (NEGATIVE)
*
* SECTIONS: objects, inheritance
* NUMBER: 18
* DESCRIPTION: Access to class members in the super constructor call of an object.
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25289
*/
open class Foo(val prop: Int) {
companion object : Foo(Companion.prop)
}
fun box(): String? {
if (Foo(42) == null) return null
return "OK"
}
@@ -0,0 +1,2 @@
java.lang.ExceptionInInitializerError
_19Kt.box(19.kt:16)
@@ -0,0 +1,19 @@
/*
* KOTLIN CODEGEN BOX NOT LINKED SPEC TEST (NEGATIVE)
*
* SECTIONS: objects, inheritance
* NUMBER: 19
* DESCRIPTION: Access to class members in the super constructor call of an object.
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25289
*/
open class Foo(val prop: Int) {
object MyObject : Foo(MyObject.prop)
}
fun box(): String? {
if (Foo.MyObject == null) return null
return "OK"
}
@@ -0,0 +1,2 @@
java.lang.ExceptionInInitializerError
_2Kt.box(2.kt:18)
@@ -0,0 +1,21 @@
/*
* KOTLIN CODEGEN BOX NOT LINKED SPEC TEST (NEGATIVE)
*
* SECTIONS: objects, inheritance
* NUMBER: 2
* DESCRIPTION: Access to class members in the super constructor call of an object.
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25289
*/
open class Bar(val x: Int)
open class Foo {
companion object : Bar(Foo.Companion.x)
}
fun box(): String? {
if (Foo.Companion == null) return null
return "OK"
}
@@ -0,0 +1,2 @@
java.lang.ExceptionInInitializerError
_3Kt.box(3.kt:18)
@@ -0,0 +1,21 @@
/*
* KOTLIN CODEGEN BOX NOT LINKED SPEC TEST (NEGATIVE)
*
* SECTIONS: objects, inheritance
* NUMBER: 3
* DESCRIPTION: Access to class members in the super constructor call of an object.
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25289
*/
open class Bar(val x: Int)
open class Foo {
companion object : Bar(Companion.x)
}
fun box(): String? {
if (Foo.Companion == null) return null
return "OK"
}
@@ -0,0 +1,2 @@
java.lang.ExceptionInInitializerError
_4Kt.box(4.kt:18)
@@ -0,0 +1,21 @@
/*
* KOTLIN CODEGEN BOX NOT LINKED SPEC TEST (NEGATIVE)
*
* SECTIONS: objects, inheritance
* NUMBER: 4
* DESCRIPTION: Access to class members in the super constructor call of an object.
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25289
*/
open class Bar(val x: Int)
open class Foo {
object MyObject : Bar(MyObject.x)
}
fun box(): String? {
if (Foo.MyObject == null) return null
return "OK"
}
@@ -0,0 +1,2 @@
java.lang.ExceptionInInitializerError
_5Kt.box(5.kt:20)
@@ -0,0 +1,23 @@
/*
* KOTLIN CODEGEN BOX NOT LINKED SPEC TEST (NEGATIVE)
*
* SECTIONS: objects, inheritance
* NUMBER: 5
* DESCRIPTION: Access to class members in the super constructor call of an object.
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25289
*/
open class Bar(val x: Int)
open class Foo {
companion object : Bar(Foo.prop) {
val prop: Int = 10
}
}
fun box(): String? {
if (Foo() == null) return null
return "OK"
}
@@ -0,0 +1,2 @@
java.lang.ExceptionInInitializerError
_6Kt.box(6.kt:20)
@@ -0,0 +1,23 @@
/*
* KOTLIN CODEGEN BOX NOT LINKED SPEC TEST (NEGATIVE)
*
* SECTIONS: objects, inheritance
* NUMBER: 6
* DESCRIPTION: Access to class members in the super constructor call of an object.
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25289
*/
open class Bar(val x: Any)
open class Foo {
companion object : Bar(Foo.prop) {
private val prop: Any = object {}
}
}
fun box(): String? {
if (Foo() == null) return null
return "OK"
}
@@ -0,0 +1,2 @@
java.lang.ExceptionInInitializerError
_7Kt.box(7.kt:16)
@@ -0,0 +1,19 @@
/*
* KOTLIN CODEGEN BOX NOT LINKED SPEC TEST (NEGATIVE)
*
* SECTIONS: objects, inheritance
* NUMBER: 7
* DESCRIPTION: Access to class members in the super constructor call of an object.
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25289
*/
open class Foo(val x: Int)
object MyObject : Foo(MyObject.x)
fun box(): String? {
if (MyObject == null) return null
return "OK"
}
@@ -0,0 +1,2 @@
java.lang.ExceptionInInitializerError
_8Kt.box(8.kt:16)
@@ -0,0 +1,19 @@
/*
* KOTLIN CODEGEN BOX NOT LINKED SPEC TEST (NEGATIVE)
*
* SECTIONS: objects, inheritance
* NUMBER: 8
* DESCRIPTION: Access to class members in the super constructor call of an object.
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25289
*/
open class Foo(a: Any) {
companion object : Foo(Companion)
}
fun box(): String? {
if (Foo.Companion == null) return null
return "OK"
}
@@ -0,0 +1,15 @@
java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
Foo$Companion.<init>()V @2: invokespecial
Reason:
Type uninitializedThis (current frame, stack[1]) is not assignable to 'java/lang/Object'
Current Frame:
bci: @2
flags: { flagThisUninit }
locals: { uninitializedThis }
stack: { uninitializedThis, uninitializedThis }
Bytecode:
0x0000000: 2a2a b700 09b1
Foo.<clinit>(9.kt)
@@ -0,0 +1,19 @@
/*
* KOTLIN CODEGEN BOX NOT LINKED SPEC TEST (NEGATIVE)
*
* SECTIONS: objects, inheritance
* NUMBER: 9
* DESCRIPTION: Access to class members in the super constructor call of an object.
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25289
*/
open class Foo(a: Any) {
companion object : Foo(this)
}
fun box(): String? {
if (Foo.Companion == null) return null
return "OK"
}
@@ -0,0 +1,23 @@
/*
* KOTLIN CODEGEN BOX NOT LINKED SPEC TEST (POSITIVE)
*
* SECTIONS: objects, inheritance
* NUMBER: 1
* DESCRIPTION: Access to class members in the super constructor call of an object.
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25289
*/
open class Bar(val x: Int)
open class Foo {
companion object : Bar(Foo.prop) {
const val prop: Int = 10
}
}
fun box(): String? {
Foo()
return "OK"
}
@@ -0,0 +1,23 @@
/*
* KOTLIN CODEGEN BOX NOT LINKED SPEC TEST (POSITIVE)
*
* SECTIONS: objects, inheritance
* NUMBER: 2
* DESCRIPTION: Access to class members in the super constructor call of an object.
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-25289
*/
open class Bar(val x: Int)
open class Foo {
companion object : Bar(Foo.prop) {
private val prop: Int = 10
}
}
fun box(): String? {
Foo()
return "OK"
}
@@ -740,5 +740,162 @@ public class BlackBoxCodegenTestSpecGenerated extends AbstractBlackBoxCodegenTes
}
}
}
@TestMetadata("compiler/tests-spec/testData/codegen/box/notLinked/objects")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Objects extends AbstractBlackBoxCodegenTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInObjects() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/notLinked/objects"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Inheritance extends AbstractBlackBoxCodegenTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInInheritance() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Neg extends AbstractBlackBoxCodegenTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("1.kt")
public void test1() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/1.kt");
}
@TestMetadata("10.kt")
public void test10() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/10.kt");
}
@TestMetadata("11.kt")
public void test11() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/11.kt");
}
@TestMetadata("12.kt")
public void test12() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/12.kt");
}
@TestMetadata("13.kt")
public void test13() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/13.kt");
}
@TestMetadata("14.kt")
public void test14() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/14.kt");
}
@TestMetadata("15.kt")
public void test15() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/15.kt");
}
@TestMetadata("16.kt")
public void test16() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/16.kt");
}
@TestMetadata("17.kt")
public void test17() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/17.kt");
}
@TestMetadata("18.kt")
public void test18() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/18.kt");
}
@TestMetadata("19.kt")
public void test19() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/19.kt");
}
@TestMetadata("2.kt")
public void test2() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/2.kt");
}
@TestMetadata("3.kt")
public void test3() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/3.kt");
}
@TestMetadata("4.kt")
public void test4() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/4.kt");
}
@TestMetadata("5.kt")
public void test5() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/5.kt");
}
@TestMetadata("6.kt")
public void test6() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/6.kt");
}
@TestMetadata("7.kt")
public void test7() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/7.kt");
}
@TestMetadata("8.kt")
public void test8() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/8.kt");
}
@TestMetadata("9.kt")
public void test9() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/9.kt");
}
public void testAllFilesPresentInNeg() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
}
@TestMetadata("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/pos")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractBlackBoxCodegenTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("1.kt")
public void test1() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/pos/1.kt");
}
@TestMetadata("2.kt")
public void test2() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/pos/2.kt");
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
}
}
}
}
}