Don't create inconsistent types (with contradictive use site and declaration site variances) for star projections with corresponding contravariant type parameters during substitution

^KT-41388 Fixed
This commit is contained in:
Victor Petukhov
2020-09-02 18:51:07 +03:00
parent 94970e2d1e
commit 85d99612a2
9 changed files with 51 additions and 1 deletions
@@ -3153,6 +3153,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/casts/castGenericNull.kt");
}
@TestMetadata("dontCreateInconsistentTypeDuringStarProjectionSubstitution.kt")
public void testDontCreateInconsistentTypeDuringStarProjectionSubstitution() throws Exception {
runTest("compiler/testData/codegen/box/casts/dontCreateInconsistentTypeDuringStarProjectionSubstitution.kt");
}
@TestMetadata("intersectionTypeMultipleBounds.kt")
public void testIntersectionTypeMultipleBounds() throws Exception {
runTest("compiler/testData/codegen/box/casts/intersectionTypeMultipleBounds.kt");
@@ -0,0 +1,15 @@
interface I
interface Foo<in L : I, in M>
interface Bar<T> {
fun test(x: Foo<*, T>)
}
fun foo(x: Any) {
if (x is Bar<*>) {
x::test
}
}
fun box(): String = "OK"
@@ -3173,6 +3173,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/casts/castGenericNull.kt");
}
@TestMetadata("dontCreateInconsistentTypeDuringStarProjectionSubstitution.kt")
public void testDontCreateInconsistentTypeDuringStarProjectionSubstitution() throws Exception {
runTest("compiler/testData/codegen/box/casts/dontCreateInconsistentTypeDuringStarProjectionSubstitution.kt");
}
@TestMetadata("intersectionTypeMultipleBounds.kt")
public void testIntersectionTypeMultipleBounds() throws Exception {
runTest("compiler/testData/codegen/box/casts/intersectionTypeMultipleBounds.kt");
@@ -3173,6 +3173,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/casts/castGenericNull.kt");
}
@TestMetadata("dontCreateInconsistentTypeDuringStarProjectionSubstitution.kt")
public void testDontCreateInconsistentTypeDuringStarProjectionSubstitution() throws Exception {
runTest("compiler/testData/codegen/box/casts/dontCreateInconsistentTypeDuringStarProjectionSubstitution.kt");
}
@TestMetadata("intersectionTypeMultipleBounds.kt")
public void testIntersectionTypeMultipleBounds() throws Exception {
runTest("compiler/testData/codegen/box/casts/intersectionTypeMultipleBounds.kt");
@@ -3153,6 +3153,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/casts/castGenericNull.kt");
}
@TestMetadata("dontCreateInconsistentTypeDuringStarProjectionSubstitution.kt")
public void testDontCreateInconsistentTypeDuringStarProjectionSubstitution() throws Exception {
runTest("compiler/testData/codegen/box/casts/dontCreateInconsistentTypeDuringStarProjectionSubstitution.kt");
}
@TestMetadata("intersectionTypeMultipleBounds.kt")
public void testIntersectionTypeMultipleBounds() throws Exception {
runTest("compiler/testData/codegen/box/casts/intersectionTypeMultipleBounds.kt");