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:
committed by
Mikhail Glukhikh
parent
4da9a101cf
commit
025d063b27
+6
@@ -0,0 +1,6 @@
|
||||
class Test {
|
||||
lateinit var someRunnable: Runnable
|
||||
init {
|
||||
someRunnable = Runnable { someRunnable.run() }
|
||||
}
|
||||
}
|
||||
+9
@@ -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
|
||||
}
|
||||
+2
-4
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user