Files
kotlin-fork/compiler/testData/diagnostics/tests/properties/kt56707.kt
T
Denis.Zharkov 3f052af517 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
2023-02-21 18:39:40 +00:00

14 lines
397 B
Kotlin
Vendored

// FIR_IDENTICAL
// WITH_STDLIB
// ISSUE: KT-56707
class Foo {
val children = mutableSetOf<Foo>()
val allChildren
get() : Set<Foo> = (children + children.flatMap { it.allChildren }).toSet() // Should not be TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM on `allChildren` reference
}
fun use() {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.Set<Foo>")!>Foo().allChildren<!>
}