[FIR] Support enhancing intersection overrides

When a type annotated with @PurelyImplements (explicitly or implicitly)
inherited some methods from a java supertype and the purely implemented
Kotlin supertype, it was inconsistent which of the signatures the
intersection override would have (with or without flexible types).
This commit adds support for the enhancement of intersection overrides.
If one of the overridden methods has non-flexible types, the enhanced
method will have non-flexible types.
This fixes some false negative nullability type mismatches.

#KT-59921 Fixed
This commit is contained in:
Kirill Rakhman
2024-01-17 10:14:44 +01:00
committed by Space Team
parent 3b841dcb98
commit 9ec0210c04
19 changed files with 159 additions and 47 deletions
@@ -0,0 +1,30 @@
// TARGET_BACKEND: JVM
// MODULE: lib
// FILE: KtWhenExpression.java
public class KtWhenExpression extends KtExpressionImpl {}
// FILE: KtExpressionImpl.kt
abstract class KtExpressionImpl : PsiElementBase(), PsiElement {}
// FILE: PsiElementBase.java
public abstract class PsiElementBase implements PsiElement {
@Override
public String getProject() { return ""; }
}
// FILE: PsiElement.java
public interface PsiElement {
String getProject();
}
// MODULE: box(lib)
// FILE: box.kt
private fun test(expression: KtWhenExpression) {
expression.project
}
fun box(): String {
test(KtWhenExpression())
return "OK"
}