Check lateinit applicability for local variables

TODO probably should be refactored together with DeclarationsChecker
This commit is contained in:
Dmitry Petrov
2017-05-31 14:53:43 +03:00
parent 3bae430d49
commit 53961e8df0
5 changed files with 74 additions and 18 deletions
@@ -0,0 +1,17 @@
// !DIAGNOSTICS: -UNUSED_VALUE -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE
import kotlin.reflect.KProperty
object Delegate {
operator fun getValue(instance: Any?, property: KProperty<*>) : String = ""
operator fun setValue(instance: Any?, property: KProperty<*>, value: String) {}
}
fun test() {
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit<!> val test0: Any
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit<!> var test1: Int
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit<!> var test2: Any?
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit<!> var test3: String = ""
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit<!> var test4 by Delegate
}
@@ -0,0 +1,12 @@
package
public fun test(): kotlin.Unit
public object Delegate {
private constructor Delegate()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final operator fun getValue(/*0*/ instance: kotlin.Any?, /*1*/ property: kotlin.reflect.KProperty<*>): kotlin.String
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final operator fun setValue(/*0*/ instance: kotlin.Any?, /*1*/ property: kotlin.reflect.KProperty<*>, /*2*/ value: kotlin.String): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}