FIR: Correctly handle nullable/flexible captured types

This commit is contained in:
Denis Zharkov
2020-11-08 18:17:40 +03:00
parent ed07bbc734
commit ce4a11144d
6 changed files with 31 additions and 1 deletions
@@ -0,0 +1,10 @@
// FILE: main.kt
fun foo(p: Processor<in CharSequence>, s: String?) {
p.process(s)
}
// FILE: Processor.java
public interface Processor<T> {
boolean process(T t);
}
@@ -0,0 +1,4 @@
FILE: main.kt
public final fun foo(p: R|Processor<in kotlin/CharSequence>|, s: R|kotlin/String?|): R|kotlin/Unit| {
R|<local>/p|.R|SubstitutionOverride</Processor.process: R|kotlin/Boolean|>|(R|<local>/s|)
}
@@ -183,6 +183,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
runTest("compiler/fir/analysis-tests/testData/resolve/fib.kt");
}
@TestMetadata("flexibleCapturedType.kt")
public void testFlexibleCapturedType() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/flexibleCapturedType.kt");
}
@TestMetadata("ft.kt")
public void testFt() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/ft.kt");
@@ -183,6 +183,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
runTest("compiler/fir/analysis-tests/testData/resolve/fib.kt");
}
@TestMetadata("flexibleCapturedType.kt")
public void testFlexibleCapturedType() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/flexibleCapturedType.kt");
}
@TestMetadata("ft.kt")
public void testFt() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/ft.kt");
@@ -183,6 +183,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
runTest("compiler/fir/analysis-tests/testData/resolve/fib.kt");
}
@TestMetadata("flexibleCapturedType.kt")
public void testFlexibleCapturedType() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/flexibleCapturedType.kt");
}
@TestMetadata("ft.kt")
public void testFt() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/ft.kt");
@@ -168,7 +168,8 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
override fun CapturedTypeMarker.lowerType(): KotlinTypeMarker? {
require(this is ConeCapturedType)
return this.lowerType
if (!this.isMarkedNullable) return this.lowerType
return this.lowerType?.makeNullable()
}
override fun TypeArgumentMarker.isStarProjection(): Boolean {