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:
Denis.Zharkov
2023-03-15 15:52:14 +01:00
committed by Space Team
parent bf977d4262
commit 823c60a7dc
6 changed files with 88 additions and 1 deletions
@@ -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() {}