Files
kotlin-fork/compiler/testData/diagnostics/tests/builderInference/issues/kt63841.fir.kt
T
Denis.Zharkov 8f9c09482b K2: Fix inference from assignment in PCLA
Before this, the order of the constraints being added was incorrect

^KT-64222 Fixed
2024-01-11 13:35:13 +00:00

51 lines
1.8 KiB
Kotlin
Vendored

// ISSUE: KT-63841
// CHECK_TYPE_WITH_EXACT
class TargetType { fun targetTypeMemberFunction() {} }
class DifferentType
fun test() {
val targetTypeBuildee = build {
var variable = getTypeVariable()
variable = TargetType()
variable.<!UNRESOLVED_REFERENCE!>targetTypeMemberFunction<!>()
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
checkExactType<Buildee<TargetType>>(targetTypeBuildee)
val differentTypeBuildee = build {
var variable = getTypeVariable()
variable = DifferentType()
variable.<!UNRESOLVED_REFERENCE!>targetTypeMemberFunction<!>()
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
checkExactType<Buildee<DifferentType>>(differentTypeBuildee)
val anyBuildee = build {
var variable = getTypeVariable()
variable = TargetType()
variable.<!UNRESOLVED_REFERENCE!>targetTypeMemberFunction<!>()
variable = DifferentType()
variable.<!UNRESOLVED_REFERENCE!>targetTypeMemberFunction<!>()
variable = TargetType()
variable.<!UNRESOLVED_REFERENCE!>targetTypeMemberFunction<!>()
}
// exact type equality check — turns unexpected compile-time behavior into red code
// considered to be non-user-reproducible code for the purposes of these tests
checkExactType<Buildee<Any>>(anyBuildee)
}
class Buildee<TV> {
fun getTypeVariable(): TV = storage
private var storage: TV = null!!
}
fun <PTV> build(instructions: Buildee<PTV>.() -> Unit): Buildee<PTV> {
return Buildee<PTV>().apply(instructions)
}