Use upper bound aware type approximator for intersection types inside sam types in contravariant positions to build proper types in terms of subtyping

This commit is contained in:
Victor Petukhov
2021-06-16 18:55:03 +03:00
committed by TeamCityServer
parent 6a78e0a10c
commit 4aeabb6b0f
21 changed files with 424 additions and 18 deletions
@@ -39182,6 +39182,40 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/sam/approximation")
@TestDataPath("$PROJECT_ROOT")
public class Approximation {
@Test
public void testAllFilesPresentInApproximation() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/sam/approximation"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("approxToIntermediateType.kt")
public void testApproxToIntermediateType() throws Exception {
runTest("compiler/testData/codegen/box/sam/approximation/approxToIntermediateType.kt");
}
@Test
@TestMetadata("approxToSingleUpperBound.kt")
public void testApproxToSingleUpperBound() throws Exception {
runTest("compiler/testData/codegen/box/sam/approximation/approxToSingleUpperBound.kt");
}
@Test
@TestMetadata("impossibleToApproxToRepresentable.kt")
public void testImpossibleToApproxToRepresentable() throws Exception {
runTest("compiler/testData/codegen/box/sam/approximation/impossibleToApproxToRepresentable.kt");
}
@Test
@TestMetadata("impossibleToApproxToRepresentable2.kt")
public void testImpossibleToApproxToRepresentable2() throws Exception {
runTest("compiler/testData/codegen/box/sam/approximation/impossibleToApproxToRepresentable2.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/box/sam/constructors")
@TestDataPath("$PROJECT_ROOT")
@@ -284,6 +284,11 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
return this.symbol.fir.bounds[index].coneType
}
override fun TypeParameterMarker.getUpperBounds(): List<KotlinTypeMarker> {
require(this is ConeTypeParameterLookupTag)
return this.symbol.fir.bounds.map { it.coneType }
}
override fun TypeParameterMarker.getTypeConstructor(): TypeConstructorMarker {
require(this is ConeTypeParameterLookupTag)
return this