Add multiplatform test with substitution, fix deep supertypes
This commit fixes ambiguity problems introduced before in MPP tests with deep supertypes #KT-29636 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
0e3fecf614
commit
bd769f8fd7
@@ -38,6 +38,8 @@ sourceSets {
|
||||
|
||||
projectTest {
|
||||
workingDir = rootDir
|
||||
jvmArgs!!.removeIf { it.contains("-Xmx") }
|
||||
maxHeapSize = "3g"
|
||||
}
|
||||
|
||||
testsJar()
|
||||
+13
-8
@@ -29,9 +29,13 @@ abstract class FirAbstractTreeTransformerWithSuperTypes(reversedScopePriority: B
|
||||
return result
|
||||
}
|
||||
|
||||
protected fun lookupSuperTypes(klass: FirRegularClass, lookupInterfaces: Boolean): List<ConeClassLikeType> {
|
||||
protected fun lookupSuperTypes(
|
||||
klass: FirRegularClass,
|
||||
lookupInterfaces: Boolean,
|
||||
deep: Boolean
|
||||
): List<ConeClassLikeType> {
|
||||
return mutableListOf<ConeClassLikeType>().also {
|
||||
if (lookupInterfaces) klass.symbol.collectSuperTypes(it)
|
||||
if (lookupInterfaces) klass.symbol.collectSuperTypes(it, deep)
|
||||
else klass.symbol.collectSuperClasses(it)
|
||||
}
|
||||
}
|
||||
@@ -63,21 +67,22 @@ abstract class FirAbstractTreeTransformerWithSuperTypes(reversedScopePriority: B
|
||||
}
|
||||
}
|
||||
|
||||
private fun ConeClassLikeSymbol.collectSuperTypes(list: MutableList<ConeClassLikeType>) {
|
||||
private fun ConeClassLikeSymbol.collectSuperTypes(list: MutableList<ConeClassLikeType>, deep: Boolean) {
|
||||
when (this) {
|
||||
is ConeClassSymbol -> {
|
||||
val superClassTypes =
|
||||
this.superTypes.mapNotNull { it.computePartialExpansion() }
|
||||
list += superClassTypes
|
||||
superClassTypes.forEach {
|
||||
if (it !is ConeClassErrorType) {
|
||||
it.symbol.collectSuperTypes(list)
|
||||
if (deep)
|
||||
superClassTypes.forEach {
|
||||
if (it !is ConeClassErrorType) {
|
||||
it.symbol.collectSuperTypes(list, deep)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
is ConeTypeAliasSymbol -> {
|
||||
val expansion = expansionType?.computePartialExpansion() ?: return
|
||||
expansion.symbol.collectSuperTypes(list)
|
||||
expansion.symbol.collectSuperTypes(list, deep)
|
||||
}
|
||||
else -> error("?!id:1")
|
||||
}
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ class FirAccessResolveTransformer : FirAbstractTreeTransformerWithSuperTypes(rev
|
||||
private fun FirRegularClass.buildUseSiteScope(useSiteSession: FirSession = session): FirClassUseSiteScope {
|
||||
val superTypeScope = FirCompositeScope(mutableListOf())
|
||||
val declaredScope = FirClassDeclaredMemberScope(this, useSiteSession)
|
||||
lookupSuperTypes(this, lookupInterfaces = true).asReversed()
|
||||
lookupSuperTypes(this, lookupInterfaces = true, deep = false)
|
||||
.mapNotNullTo(superTypeScope.scopes) { useSiteSuperType ->
|
||||
if (useSiteSuperType is ConeClassErrorType) return@mapNotNullTo null
|
||||
val symbol = useSiteSuperType.symbol
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ open class FirTypeResolveTransformer(
|
||||
return withScopeCleanup {
|
||||
val firProvider = FirProvider.getInstance(regularClass.session)
|
||||
val classId = regularClass.symbol.classId
|
||||
lookupSuperTypes(regularClass, lookupInterfaces = false).asReversed().mapTo(towerScope.scopes) {
|
||||
lookupSuperTypes(regularClass, lookupInterfaces = false, deep = true).asReversed().mapTo(towerScope.scopes) {
|
||||
val symbol = it.symbol
|
||||
if (symbol is FirBasedSymbol<*>) {
|
||||
FirNestedClassifierScope(symbol.classId, FirProvider.getInstance(symbol.fir.session))
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
abstract class A {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
interface Y {
|
||||
fun baz() {}
|
||||
}
|
||||
|
||||
open class B : A(), Y {
|
||||
fun bar() {
|
||||
foo()
|
||||
baz()
|
||||
}
|
||||
}
|
||||
|
||||
class C : B() {
|
||||
fun test() {
|
||||
foo()
|
||||
bar()
|
||||
baz()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
FILE: three.kt
|
||||
public abstract class A {
|
||||
public constructor(): super<R|kotlin/Any|>()
|
||||
|
||||
public final function foo(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
public abstract interface Y {
|
||||
public open function baz(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
public open class B : R|A|, R|Y| {
|
||||
public constructor(): super<R|A|>()
|
||||
|
||||
public final function bar(): R|kotlin/Unit| {
|
||||
R|/A.foo|()
|
||||
R|/Y.baz|()
|
||||
}
|
||||
|
||||
}
|
||||
public final class C : R|B| {
|
||||
public constructor(): super<R|B|>()
|
||||
|
||||
public final function test(): R|kotlin/Unit| {
|
||||
R|/A.foo|()
|
||||
R|/B.bar|()
|
||||
R|/Y.baz|()
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -264,6 +264,11 @@ public class FirResolveTestCaseGenerated extends AbstractFirResolveTestCase {
|
||||
public void testSimpleFakeOverride() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/overrides/simpleFakeOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("three.kt")
|
||||
public void testThree() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/overrides/three.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/fir/resolve/testData/resolve/references")
|
||||
|
||||
Reference in New Issue
Block a user