Delegated properties now cannot be used before initialization #KT-10869 Fixed

This commit is contained in:
Mikhail Glukhikh
2016-02-01 19:06:59 +03:00
parent 65f754ffca
commit 45298e0bad
10 changed files with 95 additions and 21 deletions
@@ -0,0 +1,32 @@
// See also KT-10869: Accessing lazy properties from init causes IllegalArgumentException
import kotlin.reflect.KProperty
class CustomDelegate {
operator fun getValue(thisRef: Any?, prop: KProperty<*>): String = prop.name
}
class Kaboom() {
// Here and below we should have errors for simple AND delegated
init {
<!UNINITIALIZED_VARIABLE!>delegated<!>.hashCode()
<!UNINITIALIZED_VARIABLE!>simple<!>.hashCode()
withGetter.hashCode()
}
val other = <!UNINITIALIZED_VARIABLE!>delegated<!>
val another = <!UNINITIALIZED_VARIABLE!>simple<!>
val something = withGetter
val delegated: String by CustomDelegate()
val simple = "xyz"
val withGetter: String
get() = "abc"
// No error should be here
val after = delegated
}
@@ -0,0 +1,23 @@
package
public final class CustomDelegate {
public constructor CustomDelegate()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final operator fun getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ prop: kotlin.reflect.KProperty<*>): kotlin.String
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class Kaboom {
public constructor Kaboom()
public final val after: kotlin.String
public final val another: kotlin.String = "xyz"
public final val delegated: kotlin.String
public final val other: kotlin.String
public final val simple: kotlin.String = "xyz"
public final val something: kotlin.String
public final val withGetter: kotlin.String
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}