[FIR] Report PROPERTY_WITH_NO_TYPE_NO_INITIALIZER for all properties
Currently, PROPERTY_WITH_NO_TYPE_NO_INITIALIZER is reported for local variables, but not reported for member or top-level properties. Add a check to the common `checkPropertyInitializer` for when a property type cannot be determined from the getter. This also corrects a K1 versus K2 inconsistency, where K2 would allow blocks from getters to determine property type instead of only allowing expression bodies. ^KT-59935 Fixed ^KT-60117 Fixed ^KT-60123 Fixed
This commit is contained in:
-3
@@ -1,3 +0,0 @@
|
||||
val x get() {
|
||||
return 1
|
||||
}
|
||||
+4
@@ -1,3 +1,7 @@
|
||||
// FIR_IDENTICAL
|
||||
|
||||
<!PROPERTY_WITH_NO_TYPE_NO_INITIALIZER!>val x<!> get() {
|
||||
return 1
|
||||
}
|
||||
|
||||
val y get() = 1
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
package
|
||||
|
||||
public val x: [Error type: Return type for property x cannot be resolved]
|
||||
public val y: kotlin.Int
|
||||
|
||||
|
||||
+4
-2
@@ -15,9 +15,11 @@ class C(p: Any, val v: Any) {
|
||||
// NB here we can use both 'T' (property type parameter) and 'p' (primary constructor parameter)
|
||||
val <T> List<T>.test3 by delegateFactory<T>(p)
|
||||
|
||||
val test4 get() { return <!UNRESOLVED_REFERENCE!>p<!> }
|
||||
<!PROPERTY_WITH_NO_TYPE_NO_INITIALIZER!>val test4<!> get() { return <!UNRESOLVED_REFERENCE!>p<!> }
|
||||
|
||||
var test5
|
||||
<!PROPERTY_WITH_NO_TYPE_NO_INITIALIZER!>var test5<!>
|
||||
get() { return <!UNRESOLVED_REFERENCE!>p<!> }
|
||||
set(nv) { <!UNRESOLVED_REFERENCE!>p<!>.let {} }
|
||||
|
||||
<!PROPERTY_WITH_NO_TYPE_NO_INITIALIZER!>lateinit var test6<!>
|
||||
}
|
||||
|
||||
Vendored
+2
@@ -20,4 +20,6 @@ class C(p: Any, val v: Any) {
|
||||
<!PROPERTY_WITH_NO_TYPE_NO_INITIALIZER!>var test5<!>
|
||||
get() { return <!UNRESOLVED_REFERENCE!>p<!> }
|
||||
set(nv) { <!UNRESOLVED_REFERENCE!>p<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>let<!> {} }
|
||||
|
||||
<!PROPERTY_WITH_NO_TYPE_NO_INITIALIZER!>lateinit var test6<!>
|
||||
}
|
||||
Vendored
+1
@@ -8,6 +8,7 @@ public final class C {
|
||||
public final val test2: kotlin.Any
|
||||
public final val test4: [Error type: Return type for property test4 cannot be resolved]
|
||||
public final var test5: [Error type: Return type for property test5 cannot be resolved]
|
||||
public final lateinit var test6: [Error type: Return type for property test6 cannot be resolved]
|
||||
public final val v: kotlin.Any
|
||||
public final val </*0*/ T> kotlin.collections.List<T>.test3: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
|
||||
Reference in New Issue
Block a user