[NI] Don't consider Nothing-constraint as proper to complete call
Follow-up of 9b3e17f0. There we decided to complete call if a type
variable from a return type has proper lower constraints, now we refine
this rule wrt `Nothing`-like constraints to avoid inferring type variables
to Nothing, which is quite useless
#KT-30370 Fixed
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline fun <T> foo(f: () -> T): String {
|
||||
return (f() as? Inv<T>)?.result() ?: "Bad"
|
||||
}
|
||||
|
||||
class Inv<T> {
|
||||
fun result(): String = "OK"
|
||||
}
|
||||
|
||||
fun <K> create(): Inv<K> = Inv()
|
||||
|
||||
fun test(b: Boolean): String {
|
||||
return foo {
|
||||
if (!b) {
|
||||
return@foo create<String>()
|
||||
}
|
||||
|
||||
if (b) {
|
||||
create()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return test(true)
|
||||
}
|
||||
Reference in New Issue
Block a user