[FE] Consider derived class tag on caching substitution scopes

This commit is contained in:
Yan Zhulanow
2022-11-18 01:16:29 +09:00
committed by Space Team
parent fe69b21aed
commit 0e050ae7f1
7 changed files with 111 additions and 5 deletions
@@ -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);
}
@Test
@TestMetadata("delegatedConstructor.kt")
public void testDelegatedConstructor() throws Exception {
runTest("compiler/testData/diagnostics/tests/subtyping/delegatedConstructor.kt");
}
@Test
@TestMetadata("extFunctionTypeAsSuperType.kt")
public void testExtFunctionTypeAsSuperType() throws Exception {
@@ -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);
}
@Test
@TestMetadata("delegatedConstructor.kt")
public void testDelegatedConstructor() throws Exception {
runTest("compiler/testData/diagnostics/tests/subtyping/delegatedConstructor.kt");
}
@Test
@TestMetadata("extFunctionTypeAsSuperType.kt")
public void testExtFunctionTypeAsSuperType() throws Exception {
@@ -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);
}
@Test
@TestMetadata("delegatedConstructor.kt")
public void testDelegatedConstructor() throws Exception {
runTest("compiler/testData/diagnostics/tests/subtyping/delegatedConstructor.kt");
}
@Test
@TestMetadata("extFunctionTypeAsSuperType.kt")
public void testExtFunctionTypeAsSuperType() throws Exception {
@@ -83,7 +83,10 @@ class FirKotlinScopeProvider(
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>()
fun FirClass.unsubstitutedScope(
@@ -162,10 +165,14 @@ private fun FirClass.scopeForClassImpl(
val basicScope = unsubstitutedScope(useSiteSession, scopeSession, withForcedTypeCalculator = false)
if (substitutor == ConeSubstitutor.Empty) return basicScope
val key = ConeSubstitutionScopeKey(classFirDispatchReceiver.symbol.toLookupTag(), isFromExpectClass, substitutor)
return scopeSession.getOrBuild(
this, key
) {
val key = ConeSubstitutionScopeKey(
classFirDispatchReceiver.symbol.toLookupTag(),
isFromExpectClass,
substitutor,
derivedClassLookupTag
)
return scopeSession.getOrBuild(this, key) {
FirClassSubstitutionScope(
useSiteSession,
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
}
}
}
@@ -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);
}
@Test
@TestMetadata("delegatedConstructor.kt")
public void testDelegatedConstructor() throws Exception {
runTest("compiler/testData/diagnostics/tests/subtyping/delegatedConstructor.kt");
}
@Test
@TestMetadata("extFunctionTypeAsSuperType.kt")
public void testExtFunctionTypeAsSuperType() throws Exception {