Files
kotlin-fork/compiler/testData/ir/irText/fakeOverrides/void/basicVoidOverride.kt
T
Kirill Rakhman 69a7bf7f68 [FIR] Add equality constraint from expected type for some synthetic function calls
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
2024-03-05 17:38:59 +00:00

24 lines
361 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// FILE: Java1.java
public class Java1 {
public Void foo(){
return null;
}
}
// FILE: 1.kt
class A : Java1()
class B : Java1() {
override fun foo(): Void {
return null!!
}
}
fun test() {
val k: Void? = A().foo()
val k2: Any = A().foo()
val k3: Void = B().foo()
val k4: Any = B().foo()
}