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
14 lines
438 B
Kotlin
Vendored
14 lines
438 B
Kotlin
Vendored
// ISSUE: KT-49024
|
|
|
|
class Foo
|
|
class Bar<T1: <!FINAL_UPPER_BOUND!>Foo<!>, out T2>
|
|
class Baz<T1, T2: Bar<Foo, out T2>>
|
|
class Qux<T1, T2: Baz<T2, <!UPPER_BOUND_VIOLATED!>Bar<Foo, T2><!>>>(var f: T2)
|
|
|
|
class Quux<T> {
|
|
fun test(): Unit {
|
|
val x: Qux<in T, <!UPPER_BOUND_VIOLATED!>Baz<T, <!UPPER_BOUND_VIOLATED!>Bar<Foo, <!CONFLICTING_PROJECTION!>in<!> T><!>><!>> = <!INITIALIZER_TYPE_MISMATCH!>null!!<!>
|
|
x.f = null!!
|
|
}
|
|
}
|