K2: Fix false-positive UNSAFE_CALL on safe call with flexible type alias
The idea of the fix is just unwrapping flexible version of type alias, before creating a not-nullable version for safe-call subject. Otherwise, it was remained to be JsExpressionResult after applying makeConeTypeDefinitelyNotNullOrNotNull (and the type is still nullable) ^KT-57190 Fixed
This commit is contained in:
committed by
Space Team
parent
bf977d4262
commit
823c60a7dc
@@ -0,0 +1,23 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-57190
|
||||
// FILE: MyFunction.java
|
||||
@FunctionalInterface
|
||||
public interface MyFunction<T> {
|
||||
void apply(T t);
|
||||
}
|
||||
|
||||
// FILE: MyPromise.java
|
||||
public interface MyPromise<T> {
|
||||
void then(MyFunction<T> done);
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
typealias JsExpressionResult = String?
|
||||
|
||||
fun countElementsByXpathAsync(promise: MyPromise<JsExpressionResult>, t: JsExpressionResult) {
|
||||
promise.then {
|
||||
it?.foo() // K1: ok, K2: was UNSAFE_CALL
|
||||
}
|
||||
}
|
||||
|
||||
fun String.foo() {}
|
||||
Reference in New Issue
Block a user