KT-3389: Local class construction results in CompilationException && KT-2873 && KT-3210
KT-2873: VerifyError on instantiating a local class inside a closure KT-3210 Inline Class: CompilationException: Back-end (JVM) Internal error: wrong code generated java.lang.ArrayIndexOutOfBoundsException null #KT-3389 Fixed
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package test
|
||||
|
||||
fun A.a(): String {
|
||||
class B {
|
||||
val b : String
|
||||
get() = this@a.s
|
||||
}
|
||||
return B().b
|
||||
}
|
||||
|
||||
class A {
|
||||
val s : String = "OK"
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
return A().a()
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package test
|
||||
|
||||
val A.a: String
|
||||
get() {
|
||||
class B {
|
||||
val b : String
|
||||
get() = this@a.s
|
||||
}
|
||||
return B().b
|
||||
}
|
||||
|
||||
class A {
|
||||
val s : String = "OK"
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
return A().a
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package test
|
||||
|
||||
class C(val s : String) {
|
||||
fun A.a(): String {
|
||||
class B {
|
||||
val b : String
|
||||
get() = this@a.s + this@C.s
|
||||
}
|
||||
return B().b
|
||||
}
|
||||
|
||||
fun test(a : A) : String {
|
||||
return a.a()
|
||||
}
|
||||
}
|
||||
|
||||
class A(val s: String) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
return C("K").test(A("O"))
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package test
|
||||
|
||||
class C(val s : String) {
|
||||
val A.a: String
|
||||
get() {
|
||||
class B {
|
||||
val b : String
|
||||
get() = this@a.s + this@C.s
|
||||
}
|
||||
return B().b
|
||||
}
|
||||
|
||||
fun test(a : A) : String {
|
||||
return a.a
|
||||
}
|
||||
}
|
||||
|
||||
class A(val s: String) {
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
return C("K").test(A("O"))
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
class A {
|
||||
val a = 1
|
||||
fun calc () : Int {
|
||||
class B() {
|
||||
val b = 2
|
||||
inner class C {
|
||||
val c = 3
|
||||
fun calc() = this@A.a + this@B.b + this.c
|
||||
}
|
||||
}
|
||||
return B().C().calc()
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
return if (A().calc() == 6) "OK" else "fail"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fun foo() : String {
|
||||
val u = {
|
||||
class B(val data : String)
|
||||
B("OK").data
|
||||
}
|
||||
return u()
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
foo()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return foo()
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.example
|
||||
|
||||
trait SomeTrait {}
|
||||
|
||||
trait KotlinProcessor<T> {
|
||||
fun execute(callback: KotlinCallback<T>?);
|
||||
}
|
||||
|
||||
trait KotlinCallback<T> {
|
||||
fun on(t : T);
|
||||
}
|
||||
|
||||
public class Test(name : String) : KotlinProcessor<SomeTrait> {
|
||||
public override fun execute(callback: KotlinCallback<SomeTrait>?) {
|
||||
if(callback != null) {
|
||||
class InlineTrait : SomeTrait {}
|
||||
|
||||
var inlineTrait = InlineTrait()
|
||||
callback.on(inlineTrait)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
var f = "fail"
|
||||
Test("OK").execute(object : KotlinCallback<SomeTrait> {
|
||||
override fun on(t: SomeTrait) {
|
||||
f = "OK"
|
||||
}
|
||||
})
|
||||
return f
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package t
|
||||
|
||||
class Reproduce {
|
||||
|
||||
fun test(): String {
|
||||
[data] class Foo(val bar: String, val baz: Int)
|
||||
val foo = Foo("OK", 5)
|
||||
return foo.bar
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
return Reproduce().test()
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class A {
|
||||
fun a () : String {
|
||||
class B() {
|
||||
fun s() : String = "OK"
|
||||
}
|
||||
return B().s()
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
return A().a()
|
||||
}
|
||||
Reference in New Issue
Block a user