[FE 1.0] Don't throw empty intersection exception, return empty intersection type instead
This commit is contained in:
committed by
teamcity
parent
a798fe0b18
commit
5b5da025f4
+6
@@ -13670,6 +13670,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/discardInapplicableCandidateWithNotSatisfyingSelfType.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/discardInapplicableCandidateWithNotSatisfyingSelfType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("dontThrowEmptyIntersectionException.kt")
|
||||||
|
public void testDontThrowEmptyIntersectionException() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/dontThrowEmptyIntersectionException.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("equalitySubstitutionInsideNonInvariantType.kt")
|
@TestMetadata("equalitySubstitutionInsideNonInvariantType.kt")
|
||||||
public void testEqualitySubstitutionInsideNonInvariantType() throws Exception {
|
public void testEqualitySubstitutionInsideNonInvariantType() throws Exception {
|
||||||
|
|||||||
+6
@@ -13670,6 +13670,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/discardInapplicableCandidateWithNotSatisfyingSelfType.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/discardInapplicableCandidateWithNotSatisfyingSelfType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("dontThrowEmptyIntersectionException.kt")
|
||||||
|
public void testDontThrowEmptyIntersectionException() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/dontThrowEmptyIntersectionException.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("equalitySubstitutionInsideNonInvariantType.kt")
|
@TestMetadata("equalitySubstitutionInsideNonInvariantType.kt")
|
||||||
public void testEqualitySubstitutionInsideNonInvariantType() throws Exception {
|
public void testEqualitySubstitutionInsideNonInvariantType() throws Exception {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilderImpl;
|
|||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind;
|
import org.jetbrains.kotlin.types.error.ErrorTypeKind;
|
||||||
import org.jetbrains.kotlin.types.error.ErrorUtils;
|
import org.jetbrains.kotlin.types.error.ErrorUtils;
|
||||||
|
import org.jetbrains.kotlin.types.typeUtil.TypeUtilsKt;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -124,7 +125,7 @@ public class TypeIntersector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bestRepresentative == null) {
|
if (bestRepresentative == null) {
|
||||||
throw new AssertionError("Empty intersection for types " + types);
|
return null;
|
||||||
}
|
}
|
||||||
return TypeUtils.makeNullableAsSpecified(bestRepresentative, allNullable);
|
return TypeUtils.makeNullableAsSpecified(bestRepresentative, allNullable);
|
||||||
}
|
}
|
||||||
|
|||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// WITH_STDLIB
|
||||||
|
|
||||||
|
// FILE: Test.java
|
||||||
|
public interface Test<K> implements I<String> {}
|
||||||
|
|
||||||
|
// FILE: Test2.java
|
||||||
|
public interface Test2<K, M>
|
||||||
|
|
||||||
|
// FILE: Test3.java
|
||||||
|
public interface Test3<K> {}
|
||||||
|
|
||||||
|
// FILE: I.java
|
||||||
|
public interface I<K> {}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
fun main(z: I<String>) {
|
||||||
|
z <!UNCHECKED_CAST!>as Test<Test2<Int, *>><!>
|
||||||
|
z <!UNCHECKED_CAST!>as Test<Test2<Int, <!UNRESOLVED_REFERENCE!>Foo<!>>><!>
|
||||||
|
z as Test<<!UNRESOLVED_REFERENCE!>Foo<!>>
|
||||||
|
z as <!UNRESOLVED_REFERENCE!>Any2<!>
|
||||||
|
println(z)
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// WITH_STDLIB
|
||||||
|
|
||||||
|
// FILE: Test.java
|
||||||
|
public interface Test<K> implements I<String> {}
|
||||||
|
|
||||||
|
// FILE: Test2.java
|
||||||
|
public interface Test2<K, M>
|
||||||
|
|
||||||
|
// FILE: Test3.java
|
||||||
|
public interface Test3<K> {}
|
||||||
|
|
||||||
|
// FILE: I.java
|
||||||
|
public interface I<K> {}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
fun main(z: I<String>) {
|
||||||
|
z <!UNCHECKED_CAST!>as Test<Test2<Int, *>><!>
|
||||||
|
z <!USELESS_CAST!>as Test<Test2<Int, <!UNRESOLVED_REFERENCE!>Foo<!>>><!>
|
||||||
|
z <!USELESS_CAST!>as Test<<!UNRESOLVED_REFERENCE!>Foo<!>><!>
|
||||||
|
z as <!UNRESOLVED_REFERENCE!>Any2<!>
|
||||||
|
println(z)
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun main(/*0*/ z: I<kotlin.String>): kotlin.Unit
|
||||||
|
|
||||||
|
public interface I</*0*/ K : kotlin.Any!> {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface Test</*0*/ K : kotlin.Any!> : I<kotlin.String!> {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface Test2</*0*/ K : kotlin.Any!, /*1*/ M : kotlin.Any!> {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface Test3</*0*/ K : kotlin.Any!> {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
Generated
+6
@@ -13676,6 +13676,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/discardInapplicableCandidateWithNotSatisfyingSelfType.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/discardInapplicableCandidateWithNotSatisfyingSelfType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("dontThrowEmptyIntersectionException.kt")
|
||||||
|
public void testDontThrowEmptyIntersectionException() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/dontThrowEmptyIntersectionException.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("equalitySubstitutionInsideNonInvariantType.kt")
|
@TestMetadata("equalitySubstitutionInsideNonInvariantType.kt")
|
||||||
public void testEqualitySubstitutionInsideNonInvariantType() throws Exception {
|
public void testEqualitySubstitutionInsideNonInvariantType() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user