FIR: Fix interface delegation case via type alias
This commit is contained in:
+6
@@ -13176,6 +13176,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/delegation/simple1.0.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("viaTypeAlias.kt")
|
||||
public void testViaTypeAlias() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegation/viaTypeAlias.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("withDefaultParameters.kt")
|
||||
public void testWithDefaultParameters() throws Exception {
|
||||
|
||||
@@ -15,10 +15,8 @@ import org.jetbrains.kotlin.fir.scopes.impl.*
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.coneType
|
||||
import org.jetbrains.kotlin.fir.typeContext
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
|
||||
class KotlinScopeProvider(
|
||||
val declaredMemberScopeDecorator: (
|
||||
@@ -110,7 +108,7 @@ fun ConeKotlinType.scopeForSupertype(
|
||||
if (this is ConeClassErrorType) return null
|
||||
val symbol = lookupTag.toSymbol(useSiteSession)
|
||||
return if (symbol is FirRegularClassSymbol) {
|
||||
val delegateField = delegateFields?.find { it.returnTypeRef.coneType == this }
|
||||
val delegateField = delegateFields?.find { useSiteSession.typeContext.equalTypes(it.returnTypeRef.coneType, this) }
|
||||
symbol.fir.scopeForSupertype(
|
||||
substitutor(symbol, this, useSiteSession),
|
||||
useSiteSession, scopeSession, delegateField,
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||
import org.jetbrains.kotlin.resolve.calls.NewCommonSuperTypeCalculator
|
||||
import org.jetbrains.kotlin.types.AbstractStrictEqualityTypeChecker
|
||||
import org.jetbrains.kotlin.types.AbstractTypeApproximator
|
||||
import org.jetbrains.kotlin.types.AbstractTypeChecker
|
||||
import org.jetbrains.kotlin.types.TypeApproximatorConfiguration
|
||||
import org.jetbrains.kotlin.types.model.*
|
||||
|
||||
@@ -44,6 +45,9 @@ fun ConeInferenceContext.intersectTypesOrNull(types: List<ConeKotlinType>): Cone
|
||||
}
|
||||
}
|
||||
|
||||
fun TypeCheckerProviderContext.equalTypes(a: ConeKotlinType, b: ConeKotlinType): Boolean =
|
||||
AbstractTypeChecker.equalTypes(this, a, b)
|
||||
|
||||
fun ConeDefinitelyNotNullType.Companion.create(original: ConeKotlinType): ConeDefinitelyNotNullType? {
|
||||
return when {
|
||||
original is ConeDefinitelyNotNullType -> original
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
public interface MyMap<K, V> {
|
||||
fun get(k: K): V
|
||||
}
|
||||
|
||||
typealias MyMapAlias<X, Y> = MyMap<X, Y>
|
||||
|
||||
abstract class A<T, E>(val m: MyMapAlias<T, E>) : MyMapAlias<T, E> by m
|
||||
|
||||
class B : A<String, String>(object : MyMap<String, String> {
|
||||
override fun get(w: String): String {
|
||||
return w + "K"
|
||||
}
|
||||
})
|
||||
|
||||
fun box(): String {
|
||||
return B().get("O")
|
||||
}
|
||||
+6
@@ -13176,6 +13176,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/delegation/simple1.0.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("viaTypeAlias.kt")
|
||||
public void testViaTypeAlias() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegation/viaTypeAlias.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("withDefaultParameters.kt")
|
||||
public void testWithDefaultParameters() throws Exception {
|
||||
|
||||
+6
@@ -13176,6 +13176,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/delegation/simple1.0.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("viaTypeAlias.kt")
|
||||
public void testViaTypeAlias() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegation/viaTypeAlias.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("withDefaultParameters.kt")
|
||||
public void testWithDefaultParameters() throws Exception {
|
||||
|
||||
+5
@@ -10788,6 +10788,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/delegation/simple1.0.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("viaTypeAlias.kt")
|
||||
public void testViaTypeAlias() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegation/viaTypeAlias.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withDefaultParameters.kt")
|
||||
public void testWithDefaultParameters() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt");
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+5
@@ -9588,6 +9588,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
runTest("compiler/testData/codegen/box/delegation/kt8154.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("viaTypeAlias.kt")
|
||||
public void testViaTypeAlias() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegation/viaTypeAlias.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withDefaultParameters.kt")
|
||||
public void testWithDefaultParameters() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt");
|
||||
|
||||
Generated
+5
@@ -9073,6 +9073,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/delegation/kt8154.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("viaTypeAlias.kt")
|
||||
public void testViaTypeAlias() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegation/viaTypeAlias.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withDefaultParameters.kt")
|
||||
public void testWithDefaultParameters() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt");
|
||||
|
||||
Generated
+5
@@ -9073,6 +9073,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/delegation/kt8154.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("viaTypeAlias.kt")
|
||||
public void testViaTypeAlias() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegation/viaTypeAlias.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withDefaultParameters.kt")
|
||||
public void testWithDefaultParameters() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt");
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java
Generated
+5
@@ -4252,6 +4252,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
runTest("compiler/testData/codegen/box/delegation/kt8154.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("viaTypeAlias.kt")
|
||||
public void testViaTypeAlias() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegation/viaTypeAlias.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withDefaultParameters.kt")
|
||||
public void testWithDefaultParameters() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt");
|
||||
|
||||
Reference in New Issue
Block a user