[NoArg] Reorganize module structure of NoArg plugin
This commit is contained in:
committed by
teamcity
parent
0f757c300a
commit
8fc4962213
+31
@@ -0,0 +1,31 @@
|
||||
// WITH_STDLIB
|
||||
// INVOKE_INITIALIZERS
|
||||
|
||||
annotation class NoArg
|
||||
|
||||
class Simple(val a: String)
|
||||
|
||||
@NoArg
|
||||
class Test(val a: String) {
|
||||
val x = 5
|
||||
val y = Simple("Hello, world!")
|
||||
val z by lazy { "TEST" }
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
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"
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
annotation class NoArg
|
||||
|
||||
class Simple(val a: String)
|
||||
|
||||
@NoArg
|
||||
class Test(val a: String) {
|
||||
val x = 5
|
||||
val y: Simple? = Simple("Hello, world!")
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val test = Test::class.java.newInstance()
|
||||
|
||||
if (test.x != 0) {
|
||||
return "Bad 5"
|
||||
}
|
||||
|
||||
if (test.y != null) {
|
||||
return "Bad Hello, world!"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
annotation class NoArg
|
||||
|
||||
sealed class Test {
|
||||
abstract val test: String
|
||||
|
||||
@NoArg
|
||||
data class Test1(override val test: String) : Test()
|
||||
|
||||
@NoArg
|
||||
data class Test2(override val test: String) : Test()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
Test::class.java.declaredConstructors.forEach { it.isAccessible = true }
|
||||
Test.Test1::class.java.declaredConstructors.forEach { it.isAccessible = true }
|
||||
|
||||
val instance = Test.Test1::class.java.newInstance() // Error
|
||||
|
||||
Demo.Foo::class.java.newInstance()
|
||||
Demo.Free::class.java.newInstance()
|
||||
|
||||
A.Free::class.java.newInstance()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@NoArg
|
||||
sealed class Demo(val name : String) {
|
||||
@NoArg
|
||||
class Free(name: String)
|
||||
|
||||
@NoArg
|
||||
class Foo(name: String) : Demo(name)
|
||||
|
||||
@NoArg
|
||||
class Bar(name: String) : Demo(name)
|
||||
}
|
||||
|
||||
@NoArg
|
||||
abstract class A(val name: String) {
|
||||
@NoArg
|
||||
class Free(name: String) : A(name)
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
annotation class NoArg
|
||||
|
||||
@NoArg
|
||||
class Foo(val s1: String) {
|
||||
val s2: String = ""
|
||||
val l: List<String> = listOf()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val instance = Foo::class.java.newInstance()
|
||||
return "OK"
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
annotation class NoArg
|
||||
|
||||
@NoArg
|
||||
class AuthenticationConfiguration(tokenExpiresIn: Long) {
|
||||
var tokenExpiryDate: String?
|
||||
|
||||
init {
|
||||
tokenExpiryDate = tokenExpiresIn.toString()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val instance = AuthenticationConfiguration::class.java.newInstance()
|
||||
|
||||
if (instance.tokenExpiryDate != null) {
|
||||
return "Initializer invoked"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// WITH_STDLIB
|
||||
// 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
@@ -0,0 +1,14 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
annotation class NoArg
|
||||
|
||||
class Outer {
|
||||
@NoArg
|
||||
class Nested(val a: String)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
Outer.Nested::class.java.newInstance()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
annotation class NoArg
|
||||
|
||||
@NoArg
|
||||
sealed class MappedSuperClass
|
||||
|
||||
@NoArg
|
||||
class ConcreteClass(val x: String) : MappedSuperClass()
|
||||
|
||||
fun box(): String {
|
||||
ConcreteClass::class.java.getConstructor().newInstance()
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
annotation class NoArg
|
||||
|
||||
@NoArg
|
||||
class Test(val a: String)
|
||||
|
||||
fun box(): String {
|
||||
Test::class.java.newInstance()
|
||||
return "OK"
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
annotation class NoArg
|
||||
|
||||
open class Base1
|
||||
open class Base2(val a: Int = 1)
|
||||
open class Base3(val a: Int) {
|
||||
@JvmOverloads constructor(a: Long = 1L) : this(a.toInt())
|
||||
}
|
||||
|
||||
@NoArg class Test1(val b: String) : Base1()
|
||||
@NoArg class Test2(val b: String) : Base2()
|
||||
@NoArg class Test3(val b: String) : Base3()
|
||||
|
||||
fun box(): String {
|
||||
val test1 = Test1::class.java.newInstance()
|
||||
val test2 = Test2::class.java.newInstance()
|
||||
if (test2.a != 1) return "fail@test2: ${test2.a}"
|
||||
val test3 = Test3::class.java.newInstance()
|
||||
if (test3.a != 1) return "fail@test3: ${test3.a}"
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user