From 8c0ad321e23625da94e1e811440773794fdf97c0 Mon Sep 17 00:00:00 2001 From: "victor.petukhov" Date: Fri, 14 Dec 2018 13:45:15 +0300 Subject: [PATCH] Add black box tests for objects inheritance problem (KT-25289) --- compiler/tests-spec/build.gradle.kts | 5 +- .../inheritance/neg/1.exceptions.runtime.txt | 2 + .../notLinked/objects/inheritance/neg/1.kt | 21 +++ .../inheritance/neg/10.exceptions.runtime.txt | 2 + .../notLinked/objects/inheritance/neg/10.kt | 20 +++ .../inheritance/neg/11.exceptions.runtime.txt | 2 + .../notLinked/objects/inheritance/neg/11.kt | 23 +++ .../inheritance/neg/12.exceptions.runtime.txt | 2 + .../notLinked/objects/inheritance/neg/12.kt | 21 +++ .../inheritance/neg/13.exceptions.runtime.txt | 15 ++ .../notLinked/objects/inheritance/neg/13.kt | 19 +++ .../inheritance/neg/14.exceptions.runtime.txt | 2 + .../notLinked/objects/inheritance/neg/14.kt | 19 +++ .../inheritance/neg/15.exceptions.runtime.txt | 2 + .../notLinked/objects/inheritance/neg/15.kt | 19 +++ .../inheritance/neg/16.exceptions.runtime.txt | 15 ++ .../notLinked/objects/inheritance/neg/16.kt | 19 +++ .../inheritance/neg/17.exceptions.runtime.txt | 15 ++ .../notLinked/objects/inheritance/neg/17.kt | 19 +++ .../inheritance/neg/18.exceptions.runtime.txt | 2 + .../notLinked/objects/inheritance/neg/18.kt | 19 +++ .../inheritance/neg/19.exceptions.runtime.txt | 2 + .../notLinked/objects/inheritance/neg/19.kt | 19 +++ .../inheritance/neg/2.exceptions.runtime.txt | 2 + .../notLinked/objects/inheritance/neg/2.kt | 21 +++ .../inheritance/neg/3.exceptions.runtime.txt | 2 + .../notLinked/objects/inheritance/neg/3.kt | 21 +++ .../inheritance/neg/4.exceptions.runtime.txt | 2 + .../notLinked/objects/inheritance/neg/4.kt | 21 +++ .../inheritance/neg/5.exceptions.runtime.txt | 2 + .../notLinked/objects/inheritance/neg/5.kt | 23 +++ .../inheritance/neg/6.exceptions.runtime.txt | 2 + .../notLinked/objects/inheritance/neg/6.kt | 23 +++ .../inheritance/neg/7.exceptions.runtime.txt | 2 + .../notLinked/objects/inheritance/neg/7.kt | 19 +++ .../inheritance/neg/8.exceptions.runtime.txt | 2 + .../notLinked/objects/inheritance/neg/8.kt | 19 +++ .../inheritance/neg/9.exceptions.runtime.txt | 15 ++ .../notLinked/objects/inheritance/neg/9.kt | 19 +++ .../notLinked/objects/inheritance/pos/1.kt | 23 +++ .../notLinked/objects/inheritance/pos/2.kt | 23 +++ .../BlackBoxCodegenTestSpecGenerated.java | 157 ++++++++++++++++++ 42 files changed, 680 insertions(+), 2 deletions(-) create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/1.exceptions.runtime.txt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/1.kt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/10.exceptions.runtime.txt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/10.kt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/11.exceptions.runtime.txt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/11.kt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/12.exceptions.runtime.txt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/12.kt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/13.exceptions.runtime.txt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/13.kt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/14.exceptions.runtime.txt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/14.kt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/15.exceptions.runtime.txt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/15.kt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/16.exceptions.runtime.txt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/16.kt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/17.exceptions.runtime.txt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/17.kt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/18.exceptions.runtime.txt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/18.kt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/19.exceptions.runtime.txt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/19.kt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/2.exceptions.runtime.txt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/2.kt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/3.exceptions.runtime.txt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/3.kt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/4.exceptions.runtime.txt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/4.kt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/5.exceptions.runtime.txt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/5.kt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/6.exceptions.runtime.txt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/6.kt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/7.exceptions.runtime.txt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/7.kt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/8.exceptions.runtime.txt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/8.kt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/9.exceptions.runtime.txt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/9.kt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/pos/1.kt create mode 100644 compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/pos/2.kt diff --git a/compiler/tests-spec/build.gradle.kts b/compiler/tests-spec/build.gradle.kts index bad44a56600..ddebe303e19 100644 --- a/compiler/tests-spec/build.gradle.kts +++ b/compiler/tests-spec/build.gradle.kts @@ -28,8 +28,9 @@ val remoteRunTests by task { 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 diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/1.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/1.exceptions.runtime.txt new file mode 100644 index 00000000000..c2bcdaa09c7 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/1.exceptions.runtime.txt @@ -0,0 +1,2 @@ +java.lang.ExceptionInInitializerError +_1Kt.box(1.kt:18) \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/1.kt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/1.kt new file mode 100644 index 00000000000..ea58a60d621 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/1.kt @@ -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" +} diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/10.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/10.exceptions.runtime.txt new file mode 100644 index 00000000000..e6e1d64ce73 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/10.exceptions.runtime.txt @@ -0,0 +1,2 @@ +java.lang.ExceptionInInitializerError +Foo$A.(10.kt:12) \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/10.kt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/10.kt new file mode 100644 index 00000000000..cabbb82fc31 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/10.kt @@ -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" +} diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/11.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/11.exceptions.runtime.txt new file mode 100644 index 00000000000..60b7d860a26 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/11.exceptions.runtime.txt @@ -0,0 +1,2 @@ +java.lang.ExceptionInInitializerError +_11Kt.box(11.kt:20) \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/11.kt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/11.kt new file mode 100644 index 00000000000..c46f0b4c3f5 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/11.kt @@ -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" +} diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/12.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/12.exceptions.runtime.txt new file mode 100644 index 00000000000..b2e1ecc2b21 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/12.exceptions.runtime.txt @@ -0,0 +1,2 @@ +java.lang.IllegalArgumentException: Parameter specified as non-null is null: method Foo., parameter x +Foo.(12.kt) \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/12.kt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/12.kt new file mode 100644 index 00000000000..b2d02cdb151 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/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" +} diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/13.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/13.exceptions.runtime.txt new file mode 100644 index 00000000000..c6e71711d2c --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/13.exceptions.runtime.txt @@ -0,0 +1,15 @@ +java.lang.VerifyError: Bad type on operand stack +Exception Details: + Location: + Foo$Companion.()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.(13.kt) \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/13.kt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/13.kt new file mode 100644 index 00000000000..0a746ed4bc1 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/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" +} diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/14.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/14.exceptions.runtime.txt new file mode 100644 index 00000000000..228eeac5620 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/14.exceptions.runtime.txt @@ -0,0 +1,2 @@ +java.lang.ExceptionInInitializerError +_14Kt.box(14.kt:16) \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/14.kt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/14.kt new file mode 100644 index 00000000000..f8cb3c0ddf8 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/14.kt @@ -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" +} diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/15.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/15.exceptions.runtime.txt new file mode 100644 index 00000000000..ee2b095904d --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/15.exceptions.runtime.txt @@ -0,0 +1,2 @@ +java.lang.ExceptionInInitializerError +_15Kt.box(15.kt:16) \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/15.kt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/15.kt new file mode 100644 index 00000000000..394d7c385ea --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/15.kt @@ -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" +} diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/16.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/16.exceptions.runtime.txt new file mode 100644 index 00000000000..7099f46139e --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/16.exceptions.runtime.txt @@ -0,0 +1,15 @@ +java.lang.VerifyError: Bad type on operand stack +Exception Details: + Location: + Foo$Companion.()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.(16.kt) \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/16.kt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/16.kt new file mode 100644 index 00000000000..3c6bb90839d --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/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" +} diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/17.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/17.exceptions.runtime.txt new file mode 100644 index 00000000000..7fe0d2bfc7a --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/17.exceptions.runtime.txt @@ -0,0 +1,15 @@ +java.lang.VerifyError: Bad type on operand stack +Exception Details: + Location: + Foo$Companion.()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.(17.kt) \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/17.kt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/17.kt new file mode 100644 index 00000000000..f8d4b9d918e --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/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" +} diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/18.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/18.exceptions.runtime.txt new file mode 100644 index 00000000000..438298ad7b8 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/18.exceptions.runtime.txt @@ -0,0 +1,2 @@ +java.lang.ExceptionInInitializerError +_18Kt.box(18.kt:16) \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/18.kt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/18.kt new file mode 100644 index 00000000000..0ee244b1e4e --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/18.kt @@ -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" +} diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/19.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/19.exceptions.runtime.txt new file mode 100644 index 00000000000..2523f86d725 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/19.exceptions.runtime.txt @@ -0,0 +1,2 @@ +java.lang.ExceptionInInitializerError +_19Kt.box(19.kt:16) \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/19.kt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/19.kt new file mode 100644 index 00000000000..5d20e1849e1 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/19.kt @@ -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" +} diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/2.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/2.exceptions.runtime.txt new file mode 100644 index 00000000000..0472f08bf5a --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/2.exceptions.runtime.txt @@ -0,0 +1,2 @@ +java.lang.ExceptionInInitializerError +_2Kt.box(2.kt:18) \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/2.kt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/2.kt new file mode 100644 index 00000000000..99327d60a3b --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/2.kt @@ -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" +} diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/3.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/3.exceptions.runtime.txt new file mode 100644 index 00000000000..83062f3cf55 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/3.exceptions.runtime.txt @@ -0,0 +1,2 @@ +java.lang.ExceptionInInitializerError +_3Kt.box(3.kt:18) \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/3.kt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/3.kt new file mode 100644 index 00000000000..a46a242f2e6 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/3.kt @@ -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" +} diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/4.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/4.exceptions.runtime.txt new file mode 100644 index 00000000000..6c39587322b --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/4.exceptions.runtime.txt @@ -0,0 +1,2 @@ +java.lang.ExceptionInInitializerError +_4Kt.box(4.kt:18) \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/4.kt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/4.kt new file mode 100644 index 00000000000..71ef9c31e6f --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/4.kt @@ -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" +} diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/5.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/5.exceptions.runtime.txt new file mode 100644 index 00000000000..4e640e8aaa1 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/5.exceptions.runtime.txt @@ -0,0 +1,2 @@ +java.lang.ExceptionInInitializerError +_5Kt.box(5.kt:20) \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/5.kt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/5.kt new file mode 100644 index 00000000000..fe0ebf647c2 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/5.kt @@ -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" +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/6.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/6.exceptions.runtime.txt new file mode 100644 index 00000000000..098c97a83a4 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/6.exceptions.runtime.txt @@ -0,0 +1,2 @@ +java.lang.ExceptionInInitializerError +_6Kt.box(6.kt:20) diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/6.kt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/6.kt new file mode 100644 index 00000000000..4acdb1dcfd4 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/6.kt @@ -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" +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/7.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/7.exceptions.runtime.txt new file mode 100644 index 00000000000..a5506cfd7ad --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/7.exceptions.runtime.txt @@ -0,0 +1,2 @@ +java.lang.ExceptionInInitializerError +_7Kt.box(7.kt:16) \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/7.kt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/7.kt new file mode 100644 index 00000000000..5cff4c7e5c6 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/7.kt @@ -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" +} diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/8.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/8.exceptions.runtime.txt new file mode 100644 index 00000000000..a4039e88b0c --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/8.exceptions.runtime.txt @@ -0,0 +1,2 @@ +java.lang.ExceptionInInitializerError +_8Kt.box(8.kt:16) \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/8.kt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/8.kt new file mode 100644 index 00000000000..f3a5f844668 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/8.kt @@ -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" +} diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/9.exceptions.runtime.txt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/9.exceptions.runtime.txt new file mode 100644 index 00000000000..97b60986bb1 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/9.exceptions.runtime.txt @@ -0,0 +1,15 @@ +java.lang.VerifyError: Bad type on operand stack +Exception Details: + Location: + Foo$Companion.()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.(9.kt) \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/9.kt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/9.kt new file mode 100644 index 00000000000..6c97dbb8c0f --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/neg/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" +} diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/pos/1.kt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/pos/1.kt new file mode 100644 index 00000000000..9fc940eb023 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/pos/1.kt @@ -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" +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/pos/2.kt b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/pos/2.kt new file mode 100644 index 00000000000..70d13e319a4 --- /dev/null +++ b/compiler/tests-spec/testData/codegen/box/notLinked/objects/inheritance/pos/2.kt @@ -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" +} \ No newline at end of file diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestSpecGenerated.java b/compiler/tests-spec/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestSpecGenerated.java index 87e548e9ad1..31f2efc18db 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestSpecGenerated.java +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestSpecGenerated.java @@ -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); + } + } + } + } } }