Fix class literals of objects in super constructor calls
In an expression such as "Obj::class" where Obj is an object, it's fine to consider Obj either an expression or a type and generate either Obj.INSTANCE.getClass() or Obj.class correspondingly. However, the former fails in the object's super constructor call because the INSTANCE field is not yet initialized. Thus, we force generation of Obj.class in case when Obj is an object. Note that this has been reproduced in our project, see KotlinMetadataVersionIndex
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
abstract class S<T>(val klass: Class<T>) {
|
||||
val result = klass.simpleName
|
||||
}
|
||||
|
||||
object OK : S<OK>(OK::class.java)
|
||||
|
||||
class C {
|
||||
companion object Companion : S<Companion>(Companion::class.java)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
assertEquals("Companion", C.Companion.result)
|
||||
return OK.result
|
||||
}
|
||||
Reference in New Issue
Block a user