[FE] Consider derived class tag on caching substitution scopes
This commit is contained in:
+6
@@ -31232,6 +31232,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/subtyping"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/subtyping"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("delegatedConstructor.kt")
|
||||||
|
public void testDelegatedConstructor() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/subtyping/delegatedConstructor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("extFunctionTypeAsSuperType.kt")
|
@TestMetadata("extFunctionTypeAsSuperType.kt")
|
||||||
public void testExtFunctionTypeAsSuperType() throws Exception {
|
public void testExtFunctionTypeAsSuperType() throws Exception {
|
||||||
|
|||||||
+6
@@ -31328,6 +31328,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/subtyping"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/subtyping"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("delegatedConstructor.kt")
|
||||||
|
public void testDelegatedConstructor() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/subtyping/delegatedConstructor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("extFunctionTypeAsSuperType.kt")
|
@TestMetadata("extFunctionTypeAsSuperType.kt")
|
||||||
public void testExtFunctionTypeAsSuperType() throws Exception {
|
public void testExtFunctionTypeAsSuperType() throws Exception {
|
||||||
|
|||||||
+6
@@ -31232,6 +31232,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/subtyping"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/subtyping"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("delegatedConstructor.kt")
|
||||||
|
public void testDelegatedConstructor() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/subtyping/delegatedConstructor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("extFunctionTypeAsSuperType.kt")
|
@TestMetadata("extFunctionTypeAsSuperType.kt")
|
||||||
public void testExtFunctionTypeAsSuperType() throws Exception {
|
public void testExtFunctionTypeAsSuperType() throws Exception {
|
||||||
|
|||||||
+12
-5
@@ -83,7 +83,10 @@ class FirKotlinScopeProvider(
|
|||||||
|
|
||||||
|
|
||||||
data class ConeSubstitutionScopeKey(
|
data class ConeSubstitutionScopeKey(
|
||||||
val lookupTag: ConeClassLikeLookupTag, val isFromExpectClass: Boolean, val substitutor: ConeSubstitutor
|
val lookupTag: ConeClassLikeLookupTag,
|
||||||
|
val isFromExpectClass: Boolean,
|
||||||
|
val substitutor: ConeSubstitutor,
|
||||||
|
val derivedClassLookupTag: ConeClassLikeLookupTag?
|
||||||
) : ScopeSessionKey<FirClass, FirClassSubstitutionScope>()
|
) : ScopeSessionKey<FirClass, FirClassSubstitutionScope>()
|
||||||
|
|
||||||
fun FirClass.unsubstitutedScope(
|
fun FirClass.unsubstitutedScope(
|
||||||
@@ -162,10 +165,14 @@ private fun FirClass.scopeForClassImpl(
|
|||||||
val basicScope = unsubstitutedScope(useSiteSession, scopeSession, withForcedTypeCalculator = false)
|
val basicScope = unsubstitutedScope(useSiteSession, scopeSession, withForcedTypeCalculator = false)
|
||||||
if (substitutor == ConeSubstitutor.Empty) return basicScope
|
if (substitutor == ConeSubstitutor.Empty) return basicScope
|
||||||
|
|
||||||
val key = ConeSubstitutionScopeKey(classFirDispatchReceiver.symbol.toLookupTag(), isFromExpectClass, substitutor)
|
val key = ConeSubstitutionScopeKey(
|
||||||
return scopeSession.getOrBuild(
|
classFirDispatchReceiver.symbol.toLookupTag(),
|
||||||
this, key
|
isFromExpectClass,
|
||||||
) {
|
substitutor,
|
||||||
|
derivedClassLookupTag
|
||||||
|
)
|
||||||
|
|
||||||
|
return scopeSession.getOrBuild(this, key) {
|
||||||
FirClassSubstitutionScope(
|
FirClassSubstitutionScope(
|
||||||
useSiteSession,
|
useSiteSession,
|
||||||
basicScope,
|
basicScope,
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
|
||||||
|
// MODULE: lib
|
||||||
|
|
||||||
|
// FILE: lib.kt
|
||||||
|
package lib
|
||||||
|
|
||||||
|
abstract class Base<in T>
|
||||||
|
|
||||||
|
|
||||||
|
// MODULE: test(lib)
|
||||||
|
|
||||||
|
// FILE: foo.kt
|
||||||
|
package test
|
||||||
|
|
||||||
|
import lib.Base
|
||||||
|
|
||||||
|
class Foo {
|
||||||
|
private inner class FooImpl : Base<Any?>()
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: bar.kt
|
||||||
|
package test
|
||||||
|
|
||||||
|
import lib.Base
|
||||||
|
|
||||||
|
class Bar {
|
||||||
|
private inner class BarImpl : Base<Any?>()
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
// -- Module: <lib> --
|
||||||
|
package
|
||||||
|
|
||||||
|
package lib {
|
||||||
|
|
||||||
|
public abstract class Base</*0*/ in T> {
|
||||||
|
public constructor Base</*0*/ in T>()
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- Module: <test> --
|
||||||
|
package
|
||||||
|
|
||||||
|
package test {
|
||||||
|
|
||||||
|
public final class Bar {
|
||||||
|
public constructor Bar()
|
||||||
|
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
|
||||||
|
|
||||||
|
private final inner class BarImpl : lib.Base<kotlin.Any?> {
|
||||||
|
public constructor BarImpl()
|
||||||
|
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 final class Foo {
|
||||||
|
public constructor Foo()
|
||||||
|
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
|
||||||
|
|
||||||
|
private final inner class FooImpl : lib.Base<kotlin.Any?> {
|
||||||
|
public constructor FooImpl()
|
||||||
|
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
@@ -31328,6 +31328,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/subtyping"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/subtyping"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("delegatedConstructor.kt")
|
||||||
|
public void testDelegatedConstructor() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/subtyping/delegatedConstructor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("extFunctionTypeAsSuperType.kt")
|
@TestMetadata("extFunctionTypeAsSuperType.kt")
|
||||||
public void testExtFunctionTypeAsSuperType() throws Exception {
|
public void testExtFunctionTypeAsSuperType() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user