69a7bf7f68
This fixes some cases where we infer some type variable inside one of the branches to Nothing instead of the expected type because Nothing appeared in some other branch. Specifically, we add an equality instead of a subtype constraint during completion of calls to synthetic functions for if/when, try and !!. We don't do it when the call contains a (possibly nested) elvis or is inside the RHS of an assignment. Otherwise, we would prevent some smart-casts. #KT-65882 Fixed
64 lines
1.3 KiB
Kotlin
Vendored
64 lines
1.3 KiB
Kotlin
Vendored
// FIR_IDENTICAL
|
|
// SKIP_TXT
|
|
|
|
interface Additional
|
|
interface A<T> : Additional
|
|
|
|
fun <U> aOf(): A<U> = TODO()
|
|
|
|
interface B<E>
|
|
|
|
fun <F> B<F>.convert(): A<F> = TODO()
|
|
|
|
fun foo1(x: B<String>): Any {
|
|
return if (x.hashCode() == 0) aOf() else x.convert()
|
|
}
|
|
|
|
fun foo2(x: B<String>): Additional {
|
|
return if (x.hashCode() == 0) <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>aOf<!>() else x.convert()
|
|
}
|
|
|
|
fun foo3(x: B<String>): Any {
|
|
return when {
|
|
x.hashCode() == 0 -> aOf()
|
|
else -> x.convert()
|
|
}
|
|
}
|
|
|
|
fun foo4(x: B<String>): Additional {
|
|
return when {
|
|
x.hashCode() == 0 -> <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>aOf<!>()
|
|
else -> x.convert()
|
|
}
|
|
}
|
|
|
|
fun foo5(x: B<String>): Any {
|
|
return if (x.hashCode() == 0) {
|
|
aOf()
|
|
} else {
|
|
x.convert()
|
|
}
|
|
}
|
|
|
|
fun foo6(x: B<String>): Additional {
|
|
return if (x.hashCode() == 0) {
|
|
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>aOf<!>()
|
|
} else {
|
|
x.convert()
|
|
}
|
|
}
|
|
|
|
fun foo7(x: B<String>): Any {
|
|
return when {
|
|
x.hashCode() == 0 -> { aOf() }
|
|
else -> { x.convert() }
|
|
}
|
|
}
|
|
|
|
fun foo8(x: B<String>): Additional {
|
|
return when {
|
|
x.hashCode() == 0 -> { <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>aOf<!>() }
|
|
else -> { x.convert() }
|
|
}
|
|
}
|