Delegated properties now cannot be used before initialization #KT-10869 Fixed
This commit is contained in:
+32
@@ -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
|
||||
}
|
||||
+23
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user