UNNECESSARY_LATEINIT: do not report if property is not initialized at use-site #KT-13806 Fixed

(cherry picked from commit 09c0865)
This commit is contained in:
Mikhail Glukhikh
2016-09-26 11:51:36 +03:00
committed by Mikhail Glukhikh
parent 4da9a101cf
commit 025d063b27
7 changed files with 33 additions and 8 deletions
@@ -0,0 +1,6 @@
class Test {
lateinit var someRunnable: Runnable
init {
someRunnable = Runnable { someRunnable.run() }
}
}
@@ -0,0 +1,9 @@
package
public final class Test {
public constructor Test()
public final lateinit var someRunnable: java.lang.Runnable
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
}
@@ -1,10 +1,8 @@
class Foo {
// Erroneous case: after lateinit removal, we'll have error at 'bar += baz', not here
// However, looks like we must have error at 'bar += baz' even with lateinit
// because nobody can initialize this 'bar' before constructor is called
<!UNNECESSARY_LATEINIT!>lateinit<!> var bar: String
lateinit var bar: String
constructor(baz: Int) {
// At best, we should have error here despite of lateinit
bar += baz
}
}