FIR: Fix bare type case with flexible supertypes
This commit is contained in:
+6
@@ -3901,6 +3901,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/types"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/types"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("bareWithFlexibleArg.kt")
|
||||||
|
public void testBareWithFlexibleArg() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/types/bareWithFlexibleArg.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("bareWithSubjectTypeAlias.kt")
|
@TestMetadata("bareWithSubjectTypeAlias.kt")
|
||||||
public void testBareWithSubjectTypeAlias() throws Exception {
|
public void testBareWithSubjectTypeAlias() throws Exception {
|
||||||
|
|||||||
+5
@@ -3496,6 +3496,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/types"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/types"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("bareWithFlexibleArg.kt")
|
||||||
|
public void testBareWithFlexibleArg() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/types/bareWithFlexibleArg.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("bareWithSubjectTypeAlias.kt")
|
@TestMetadata("bareWithSubjectTypeAlias.kt")
|
||||||
public void testBareWithSubjectTypeAlias() throws Exception {
|
public void testBareWithSubjectTypeAlias() throws Exception {
|
||||||
runTest("compiler/fir/analysis-tests/testData/resolve/types/bareWithSubjectTypeAlias.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/types/bareWithSubjectTypeAlias.kt");
|
||||||
|
|||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
FILE: main.kt
|
||||||
|
public final fun foo(x: R|Promise<kotlin/String?>|): R|kotlin/Unit| {
|
||||||
|
R|/bar|((R|<local>/x| as R|CancellablePromise<kotlin/String?>|))
|
||||||
|
}
|
||||||
|
public final fun bar(x: R|CancellablePromise<kotlin/String?>|): R|kotlin/Unit| {
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
// SKIP_TXT
|
||||||
|
|
||||||
|
// FILE: Promise.java
|
||||||
|
public interface Promise<T> {}
|
||||||
|
|
||||||
|
// FILE: CancellablePromise.java
|
||||||
|
public interface CancellablePromise<E> extends Promise<E> {}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
fun foo(x: Promise<String?>) {
|
||||||
|
bar(x as CancellablePromise)
|
||||||
|
}
|
||||||
|
fun bar(x: CancellablePromise<String?>) {}
|
||||||
|
|
||||||
+6
@@ -3901,6 +3901,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/types"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/types"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("bareWithFlexibleArg.kt")
|
||||||
|
public void testBareWithFlexibleArg() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/types/bareWithFlexibleArg.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("bareWithSubjectTypeAlias.kt")
|
@TestMetadata("bareWithSubjectTypeAlias.kt")
|
||||||
public void testBareWithSubjectTypeAlias() throws Exception {
|
public void testBareWithSubjectTypeAlias() throws Exception {
|
||||||
|
|||||||
+6
@@ -3901,6 +3901,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/types"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/types"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("bareWithFlexibleArg.kt")
|
||||||
|
public void testBareWithFlexibleArg() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/types/bareWithFlexibleArg.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("bareWithSubjectTypeAlias.kt")
|
@TestMetadata("bareWithSubjectTypeAlias.kt")
|
||||||
public void testBareWithSubjectTypeAlias() throws Exception {
|
public void testBareWithSubjectTypeAlias() throws Exception {
|
||||||
|
|||||||
+3
-6
@@ -97,7 +97,7 @@ private fun BodyResolveComponents.doUnify(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Foo? ~ X? => Foo ~ X
|
// Foo? ~ X? => Foo ~ X
|
||||||
if (originalType?.nullability?.isNullable == true && typeWithParameters?.nullability?.isNullable == true) {
|
if (originalType?.nullability == ConeNullability.NULLABLE && typeWithParameters?.nullability == ConeNullability.NULLABLE) {
|
||||||
return doUnify(
|
return doUnify(
|
||||||
originalTypeProjection.removeQuestionMark(session.typeContext),
|
originalTypeProjection.removeQuestionMark(session.typeContext),
|
||||||
typeWithParametersProjection.removeQuestionMark(session.typeContext),
|
typeWithParametersProjection.removeQuestionMark(session.typeContext),
|
||||||
@@ -113,17 +113,14 @@ private fun BodyResolveComponents.doUnify(
|
|||||||
|
|
||||||
if (typeWithParameters is ConeFlexibleType) {
|
if (typeWithParameters is ConeFlexibleType) {
|
||||||
return doUnify(
|
return doUnify(
|
||||||
if (originalType?.nullability?.isNullable == true)
|
originalTypeProjection,
|
||||||
originalTypeProjection.removeQuestionMark(session.typeContext)
|
|
||||||
else
|
|
||||||
originalTypeProjection,
|
|
||||||
typeWithParametersProjection.replaceType(typeWithParameters.lowerBound),
|
typeWithParametersProjection.replaceType(typeWithParameters.lowerBound),
|
||||||
targetTypeParameters, result,
|
targetTypeParameters, result,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Foo ~ X? => fail
|
// Foo ~ X? => fail
|
||||||
if (originalType?.nullability?.isNullable != true && typeWithParameters?.nullability?.isNullable == true) {
|
if (originalType?.nullability != ConeNullability.NULLABLE && typeWithParameters?.nullability == ConeNullability.NULLABLE) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user