FIR2IR: Fix incorrect fake override structure for delegated member in supertype
In C, fake override for `name` should have B::name as base symbol, not Named::name
This commit is contained in:
+3
-1
@@ -192,8 +192,10 @@ class FakeOverrideGenerator(
|
|||||||
): List<S> {
|
): List<S> {
|
||||||
if (symbol.fir.origin != FirDeclarationOrigin.IntersectionOverride) return listOf(basedSymbol)
|
if (symbol.fir.origin != FirDeclarationOrigin.IntersectionOverride) return listOf(basedSymbol)
|
||||||
return scope.directOverridden(symbol).map {
|
return scope.directOverridden(symbol).map {
|
||||||
|
// Unwrapping should happen only for fake overrides members from the same class, not from supertypes
|
||||||
|
if (it.dispatchReceiverClassOrNull() != containingClass) return@map it
|
||||||
when {
|
when {
|
||||||
it.fir.isSubstitutionOverride && it.dispatchReceiverClassOrNull() == containingClass ->
|
it.fir.isSubstitutionOverride ->
|
||||||
it.originalForSubstitutionOverride!!
|
it.originalForSubstitutionOverride!!
|
||||||
it.fir.origin == FirDeclarationOrigin.Delegated ->
|
it.fir.origin == FirDeclarationOrigin.Delegated ->
|
||||||
it.fir.delegatedWrapperData?.wrapped?.symbol!! as S
|
it.fir.delegatedWrapperData?.wrapped?.symbol!! as S
|
||||||
|
|||||||
+5
@@ -375,6 +375,11 @@ public class FirCompileKotlinAgainstKotlinTestGenerated extends AbstractFirCompi
|
|||||||
runTest("compiler/testData/compileKotlinAgainstKotlin/nestedTypeAliasExpansion.kt");
|
runTest("compiler/testData/compileKotlinAgainstKotlin/nestedTypeAliasExpansion.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noExplicitOverrideForDelegatedFromSupertype.kt")
|
||||||
|
public void testNoExplicitOverrideForDelegatedFromSupertype() throws Exception {
|
||||||
|
runTest("compiler/testData/compileKotlinAgainstKotlin/noExplicitOverrideForDelegatedFromSupertype.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("optionalAnnotation.kt")
|
@TestMetadata("optionalAnnotation.kt")
|
||||||
public void testOptionalAnnotation() throws Exception {
|
public void testOptionalAnnotation() throws Exception {
|
||||||
runTest("compiler/testData/compileKotlinAgainstKotlin/optionalAnnotation.kt");
|
runTest("compiler/testData/compileKotlinAgainstKotlin/optionalAnnotation.kt");
|
||||||
|
|||||||
Vendored
+23
@@ -0,0 +1,23 @@
|
|||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
// FILE: A.kt
|
||||||
|
package a
|
||||||
|
|
||||||
|
interface Named {
|
||||||
|
val name: String
|
||||||
|
}
|
||||||
|
|
||||||
|
interface A : Named
|
||||||
|
|
||||||
|
// FILE: B.kt
|
||||||
|
import a.*
|
||||||
|
|
||||||
|
open class B(val a: A) : A by a, Named
|
||||||
|
|
||||||
|
class C(a: A) : B(a)
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return C(object : A {
|
||||||
|
override val name: String
|
||||||
|
get() = "OK"
|
||||||
|
}).name
|
||||||
|
}
|
||||||
Generated
+5
@@ -374,6 +374,11 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl
|
|||||||
runTest("compiler/testData/compileKotlinAgainstKotlin/nestedTypeAliasExpansion.kt");
|
runTest("compiler/testData/compileKotlinAgainstKotlin/nestedTypeAliasExpansion.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noExplicitOverrideForDelegatedFromSupertype.kt")
|
||||||
|
public void testNoExplicitOverrideForDelegatedFromSupertype() throws Exception {
|
||||||
|
runTest("compiler/testData/compileKotlinAgainstKotlin/noExplicitOverrideForDelegatedFromSupertype.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("optionalAnnotation.kt")
|
@TestMetadata("optionalAnnotation.kt")
|
||||||
public void testOptionalAnnotation() throws Exception {
|
public void testOptionalAnnotation() throws Exception {
|
||||||
runTest("compiler/testData/compileKotlinAgainstKotlin/optionalAnnotation.kt");
|
runTest("compiler/testData/compileKotlinAgainstKotlin/optionalAnnotation.kt");
|
||||||
|
|||||||
Generated
+5
@@ -375,6 +375,11 @@ public class IrCompileKotlinAgainstKotlinTestGenerated extends AbstractIrCompile
|
|||||||
runTest("compiler/testData/compileKotlinAgainstKotlin/nestedTypeAliasExpansion.kt");
|
runTest("compiler/testData/compileKotlinAgainstKotlin/nestedTypeAliasExpansion.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noExplicitOverrideForDelegatedFromSupertype.kt")
|
||||||
|
public void testNoExplicitOverrideForDelegatedFromSupertype() throws Exception {
|
||||||
|
runTest("compiler/testData/compileKotlinAgainstKotlin/noExplicitOverrideForDelegatedFromSupertype.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("optionalAnnotation.kt")
|
@TestMetadata("optionalAnnotation.kt")
|
||||||
public void testOptionalAnnotation() throws Exception {
|
public void testOptionalAnnotation() throws Exception {
|
||||||
runTest("compiler/testData/compileKotlinAgainstKotlin/optionalAnnotation.kt");
|
runTest("compiler/testData/compileKotlinAgainstKotlin/optionalAnnotation.kt");
|
||||||
|
|||||||
+5
@@ -375,6 +375,11 @@ public class JvmIrAgainstOldBoxTestGenerated extends AbstractJvmIrAgainstOldBoxT
|
|||||||
runTest("compiler/testData/compileKotlinAgainstKotlin/nestedTypeAliasExpansion.kt");
|
runTest("compiler/testData/compileKotlinAgainstKotlin/nestedTypeAliasExpansion.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noExplicitOverrideForDelegatedFromSupertype.kt")
|
||||||
|
public void testNoExplicitOverrideForDelegatedFromSupertype() throws Exception {
|
||||||
|
runTest("compiler/testData/compileKotlinAgainstKotlin/noExplicitOverrideForDelegatedFromSupertype.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("optionalAnnotation.kt")
|
@TestMetadata("optionalAnnotation.kt")
|
||||||
public void testOptionalAnnotation() throws Exception {
|
public void testOptionalAnnotation() throws Exception {
|
||||||
runTest("compiler/testData/compileKotlinAgainstKotlin/optionalAnnotation.kt");
|
runTest("compiler/testData/compileKotlinAgainstKotlin/optionalAnnotation.kt");
|
||||||
|
|||||||
+5
@@ -375,6 +375,11 @@ public class JvmOldAgainstIrBoxTestGenerated extends AbstractJvmOldAgainstIrBoxT
|
|||||||
runTest("compiler/testData/compileKotlinAgainstKotlin/nestedTypeAliasExpansion.kt");
|
runTest("compiler/testData/compileKotlinAgainstKotlin/nestedTypeAliasExpansion.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noExplicitOverrideForDelegatedFromSupertype.kt")
|
||||||
|
public void testNoExplicitOverrideForDelegatedFromSupertype() throws Exception {
|
||||||
|
runTest("compiler/testData/compileKotlinAgainstKotlin/noExplicitOverrideForDelegatedFromSupertype.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("optionalAnnotation.kt")
|
@TestMetadata("optionalAnnotation.kt")
|
||||||
public void testOptionalAnnotation() throws Exception {
|
public void testOptionalAnnotation() throws Exception {
|
||||||
runTest("compiler/testData/compileKotlinAgainstKotlin/optionalAnnotation.kt");
|
runTest("compiler/testData/compileKotlinAgainstKotlin/optionalAnnotation.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user