K2: Propagate explicit getter type to the property without initializer
In K1, we have the rules like: - if there's explicit type of a property, then use it - if there's an initializer, obtain its expression-type - Otherwise, use getter's return type The case when getter's type is implicit is handled at FirDeclarationsResolveTransformer.transformProperty ^KT-56707 Fixed
This commit is contained in:
committed by
Space Team
parent
c09607c791
commit
3f052af517
Vendored
-18
@@ -1,18 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
val x get(): String = foo()
|
||||
val y get(): List<Int> = bar()
|
||||
val z get(): List<Int> {
|
||||
return bar()
|
||||
}
|
||||
|
||||
val u get(): String = <!UNRESOLVED_REFERENCE!>field<!>
|
||||
|
||||
fun <E> foo(): E = null!!
|
||||
fun <E> bar(): List<E> = null!!
|
||||
|
||||
|
||||
fun baz() {
|
||||
x checkType { _<String>() }
|
||||
y checkType { _<List<Int>>() }
|
||||
z checkType { _<List<Int>>() }
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
val x get(): String = foo()
|
||||
val y get(): List<Int> = bar()
|
||||
|
||||
Reference in New Issue
Block a user