2bafcddf7a
Namely, do not choose `Nothing?` result type when fixing a variable that has other constraints besides the ones that came from the relevant type parameter's upper bounds. See more details in KT-55691. In K1, the case from specialCallWithMaterializeAndExpectedType.kt was working (inferred to String?) just because the branches were analyzed independently with `String?` expected type. This change became necessary after the previous commit when we united inference subsystems for if/when branches (see motivation there). NB: For K1, the behavior is left the same, but the code was refactored a bit. ^KT-55691 Fixed ^KT-56448 Fixed
16 lines
429 B
Kotlin
Vendored
16 lines
429 B
Kotlin
Vendored
// FIR_IDENTICAL
|
|
// SKIP_TXT
|
|
|
|
class Out<out T : CharSequence?>(val t: T)
|
|
|
|
fun foo() {
|
|
// We have two constraints here:
|
|
// Nothing? <: T (from argument `null` type)
|
|
// T <: CharSequence?
|
|
// And we fix T to `Nothing?`, because it's still more preferrable than constraint from the upper bound
|
|
val x1 = Out(null)
|
|
bar(<!DEBUG_INFO_EXPRESSION_TYPE("Out<kotlin.Nothing?>")!>x1<!>)
|
|
}
|
|
|
|
fun bar(w: Out<String?>) {}
|