mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-16 00:21:32 +00:00
19 lines
435 B
Kotlin
Vendored
19 lines
435 B
Kotlin
Vendored
// KT-4351 Cannot resolve reference to self in init of class local to function
|
|
|
|
fun box(): String {
|
|
var accessedFromConstructor: Class<*>? = null
|
|
|
|
class MyClass() {
|
|
init {
|
|
accessedFromConstructor = MyClass::class.java
|
|
}
|
|
}
|
|
|
|
MyClass()
|
|
if (accessedFromConstructor!!.getName().endsWith("MyClass")) {
|
|
return "OK"
|
|
} else {
|
|
return accessedFromConstructor.toString()
|
|
}
|
|
}
|