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:
Denis.Zharkov
2023-02-20 16:53:33 +01:00
committed by Space Team
parent c09607c791
commit 3f052af517
10 changed files with 96 additions and 20 deletions
@@ -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,3 +1,4 @@
// FIR_IDENTICAL
// !CHECK_TYPE
val x get(): String = foo()
val y get(): List<Int> = bar()