Support captured types in ConeTypeCompatibilityChecker
This commit is contained in:
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
FILE: capturedTypeInEquality.kt
|
||||
public abstract interface FirTargetElement : R|kotlin/Any| {
|
||||
}
|
||||
public abstract interface FirFunction<F : R|FirFunction<F>|> : R|FirTargetElement| {
|
||||
}
|
||||
public abstract interface FirPropertyAccessor : R|FirFunction<FirPropertyAccessor>| {
|
||||
}
|
||||
public abstract interface FirProperty : R|kotlin/Any| {
|
||||
public abstract val getter: R|FirPropertyAccessor|
|
||||
public get(): R|FirPropertyAccessor|
|
||||
|
||||
}
|
||||
public abstract interface FirTarget<E : R|FirTargetElement|> : R|kotlin/Any| {
|
||||
public abstract val labeledElement: R|E|
|
||||
public get(): R|E|
|
||||
|
||||
}
|
||||
public final fun foo(target: R|FirTarget<FirFunction<*>>|, property: R|FirProperty|): R|kotlin/Unit| {
|
||||
lval functionTarget: R|FirFunction<*>| = R|<local>/target|.R|SubstitutionOverride</FirTarget.labeledElement: R|FirFunction<*>|>|
|
||||
lval x: R|kotlin/Int?| = (R|<local>/functionTarget| as? R|FirFunction<CapturedType(*)>|)?.{ $subj$.R|kotlin/let|<R|FirFunction<*>|, R|kotlin/Int|>(<L> = let@fun <anonymous>(it: R|FirFunction<*>|): R|kotlin/Int| <inline=Inline, kind=EXACTLY_ONCE> {
|
||||
when () {
|
||||
===(R|<local>/property|.R|/FirProperty.getter|, R|<local>/functionTarget|) -> {
|
||||
^@let Int(1)
|
||||
}
|
||||
}
|
||||
|
||||
^ Int(0)
|
||||
}
|
||||
) }
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
interface FirTargetElement
|
||||
|
||||
interface FirFunction<F : FirFunction<F>> : FirTargetElement
|
||||
|
||||
interface FirPropertyAccessor : FirFunction<FirPropertyAccessor>
|
||||
|
||||
interface FirProperty {
|
||||
val getter: FirPropertyAccessor
|
||||
}
|
||||
|
||||
interface FirTarget<E : FirTargetElement> {
|
||||
val labeledElement: E
|
||||
}
|
||||
|
||||
fun foo(target: FirTarget<FirFunction<*>>, property: FirProperty) {
|
||||
val functionTarget = target.labeledElement
|
||||
val x = (functionTarget as? FirFunction)?.let {
|
||||
if (<!EQUALITY_NOT_APPLICABLE_WARNING!>property.getter === functionTarget<!>) {
|
||||
return@let 1
|
||||
}
|
||||
0
|
||||
}
|
||||
}
|
||||
+6
@@ -5293,6 +5293,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("capturedTypeInEquality.kt")
|
||||
public void testCapturedTypeInEquality() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/capturedTypeInEquality.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("DeepCopyIrTree.kt")
|
||||
public void testDeepCopyIrTree() throws Exception {
|
||||
|
||||
+6
@@ -5293,6 +5293,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("capturedTypeInEquality.kt")
|
||||
public void testCapturedTypeInEquality() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/capturedTypeInEquality.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("DeepCopyIrTree.kt")
|
||||
public void testDeepCopyIrTree() throws Exception {
|
||||
|
||||
+4
-2
@@ -234,7 +234,8 @@ internal object ConeTypeCompatibilityChecker {
|
||||
is ConeDefinitelyNotNullType -> original.collectUpperBounds()
|
||||
is ConeIntersectionType -> intersectedTypes.flatMap { it.collectUpperBounds() }.toSet()
|
||||
is ConeFlexibleType -> upperBound.collectUpperBounds()
|
||||
is ConeCapturedType, is ConeStubType, is ConeIntegerLiteralType -> throw IllegalStateException("$this should not reach here")
|
||||
is ConeCapturedType -> constructor.supertypes?.flatMap { it.collectUpperBounds() }?.toSet().orEmpty()
|
||||
is ConeStubType, is ConeIntegerLiteralType -> throw IllegalStateException("$this should not reach here")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,7 +257,8 @@ internal object ConeTypeCompatibilityChecker {
|
||||
is ConeDefinitelyNotNullType -> original.collectLowerBounds()
|
||||
is ConeIntersectionType -> intersectedTypes.flatMap { it.collectLowerBounds() }.toSet()
|
||||
is ConeFlexibleType -> lowerBound.collectLowerBounds()
|
||||
is ConeCapturedType, is ConeStubType, is ConeIntegerLiteralType -> throw IllegalStateException("$this should not reach here")
|
||||
is ConeCapturedType -> constructor.supertypes?.flatMap { it.collectLowerBounds() }?.toSet().orEmpty()
|
||||
is ConeStubType, is ConeIntegerLiteralType -> throw IllegalStateException("$this should not reach here")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -4770,6 +4770,11 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@TestMetadata("capturedTypeInEquality.kt")
|
||||
public void testCapturedTypeInEquality() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/capturedTypeInEquality.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("DeepCopyIrTree.kt")
|
||||
public void testDeepCopyIrTree() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/DeepCopyIrTree.kt");
|
||||
|
||||
Reference in New Issue
Block a user