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
28 lines
415 B
Kotlin
Vendored
28 lines
415 B
Kotlin
Vendored
class C : Java1, Java2 {
|
|
constructor() /* primary */ {
|
|
super/*Java1*/()
|
|
/* <init>() */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
class D : Java1, Java2 {
|
|
constructor() /* primary */ {
|
|
super/*Java1*/()
|
|
/* <init>() */
|
|
|
|
}
|
|
|
|
override fun foo(): Void {
|
|
return CHECK_NOT_NULL<Nothing>(arg0 = null)
|
|
}
|
|
|
|
}
|
|
|
|
fun test() {
|
|
val k1: Any = C().foo() /*!! Void */
|
|
val k2: Void = C().foo() /*!! Void */
|
|
val k3: Void = D().foo()
|
|
}
|