JVM IR: support noarg compiler plugin

#KT-41265 Fixed
This commit is contained in:
Alexander Udalov
2020-11-25 22:23:22 +01:00
parent a06bffc4b9
commit 25c228297a
21 changed files with 483 additions and 61 deletions
+14 -19
View File
@@ -13,24 +13,19 @@ class Test(val a: String) {
}
fun box(): String {
try {
val test = Test::class.java.newInstance()
val test = Test::class.java.newInstance()
if (test.x != 5) {
return "Bad 5"
}
if (test.y == null || test.y.a != "Hello, world!") {
return "Bad Hello, world!"
}
if (test.z != "TEST") {
return "Bad TEST"
}
return "OK"
} catch (e: Throwable) {
e.printStackTrace()
return "Fail"
if (test.x != 5) {
return "Bad 5"
}
}
if (test.y == null || test.y.a != "Hello, world!") {
return "Bad Hello, world!"
}
if (test.z != "TEST") {
return "Bad TEST"
}
return "OK"
}
@@ -11,20 +11,15 @@ class Test(val a: String) {
}
fun box(): String {
try {
val test = Test::class.java.newInstance()
val test = Test::class.java.newInstance()
if (test.x != 0) {
return "Bad 5"
}
if (test.y != null) {
return "Bad Hello, world!"
}
return "OK"
} catch (e: Throwable) {
e.printStackTrace()
return "Fail"
if (test.x != 0) {
return "Bad 5"
}
}
if (test.y != null) {
return "Bad Hello, world!"
}
return "OK"
}
@@ -0,0 +1,20 @@
// WITH_RUNTIME
// INVOKE_INITIALIZERS
annotation class NoArg
@NoArg
class Test(val a: String) {
val lc = run {
class Local(val result: String)
Local("OK").result
}
val obj = object { val result = "OK" }.result
}
fun box(): String {
val t = Test::class.java.newInstance()
if (t.lc != "OK") return "Fail 1"
return t.obj
}
+14
View File
@@ -0,0 +1,14 @@
// WITH_RUNTIME
annotation class NoArg
class Outer {
@NoArg
class Nested(val a: String)
}
fun box(): String {
Outer.Nested::class.java.newInstance()
return "OK"
}
+3 -7
View File
@@ -6,10 +6,6 @@ annotation class NoArg
class Test(val a: String)
fun box(): String {
try {
Test::class.java.newInstance()
return "OK"
} catch (_: Throwable) {
return "Fail"
}
}
Test::class.java.newInstance()
return "OK"
}
@@ -0,0 +1,10 @@
annotation class NoArg
@NoArg
class Internal internal constructor(z: Boolean)
@NoArg
abstract class Protected protected constructor(c: Char)
@NoArg
class Private private constructor(ia: IntArray)
@@ -0,0 +1,29 @@
@NoArg
@kotlin.Metadata
public final class Internal {
// source: 'constructorVisibility.kt'
public method <init>(): void
public method <init>(p0: boolean): void
}
@java.lang.annotation.Retention
@kotlin.Metadata
public annotation class NoArg {
// source: 'constructorVisibility.kt'
}
@NoArg
@kotlin.Metadata
public final class Private {
// source: 'constructorVisibility.kt'
public method <init>(): void
private method <init>(p0: int[]): void
}
@NoArg
@kotlin.Metadata
public abstract class Protected {
// source: 'constructorVisibility.kt'
public method <init>(): void
protected method <init>(p0: char): void
}
@@ -0,0 +1,6 @@
annotation class NoArg
class Outer {
@NoArg
class Nested(a: Long)
}
@@ -0,0 +1,21 @@
@java.lang.annotation.Retention
@kotlin.Metadata
public annotation class NoArg {
// source: 'nestedClass.kt'
}
@NoArg
@kotlin.Metadata
public final class Outer$Nested {
// source: 'nestedClass.kt'
public method <init>(): void
public method <init>(p0: long): void
public final inner class Outer$Nested
}
@kotlin.Metadata
public final class Outer {
// source: 'nestedClass.kt'
public method <init>(): void
public final inner class Outer$Nested
}