FIR2IR: correct base symbols of fake overrides for delegated member
#KT-43984 Fixed
This commit is contained in:
committed by
TeamCityServer
parent
44c6ec2c44
commit
4608431682
+9
-9
@@ -10,11 +10,9 @@ import org.jetbrains.kotlin.fir.*
|
|||||||
import org.jetbrains.kotlin.fir.backend.*
|
import org.jetbrains.kotlin.fir.backend.*
|
||||||
import org.jetbrains.kotlin.fir.declarations.*
|
import org.jetbrains.kotlin.fir.declarations.*
|
||||||
import org.jetbrains.kotlin.fir.resolve.defaultType
|
import org.jetbrains.kotlin.fir.resolve.defaultType
|
||||||
import org.jetbrains.kotlin.fir.scopes.FirTypeScope
|
import org.jetbrains.kotlin.fir.scopes.*
|
||||||
import org.jetbrains.kotlin.fir.scopes.getDirectOverriddenFunctions
|
|
||||||
import org.jetbrains.kotlin.fir.scopes.getDirectOverriddenProperties
|
|
||||||
import org.jetbrains.kotlin.fir.scopes.impl.FirFakeOverrideGenerator
|
import org.jetbrains.kotlin.fir.scopes.impl.FirFakeOverrideGenerator
|
||||||
import org.jetbrains.kotlin.fir.scopes.unsubstitutedScope
|
import org.jetbrains.kotlin.fir.scopes.impl.delegatedWrapperData
|
||||||
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||||
@@ -194,11 +192,13 @@ 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 {
|
||||||
@Suppress("UNCHECKED_CAST")
|
when {
|
||||||
if (it.fir.isSubstitutionOverride && it.dispatchReceiverClassOrNull() == containingClass)
|
it.fir.isSubstitutionOverride && it.dispatchReceiverClassOrNull() == containingClass ->
|
||||||
it.originalForSubstitutionOverride!!
|
it.originalForSubstitutionOverride!!
|
||||||
else
|
it.fir.origin == FirDeclarationOrigin.Delegated ->
|
||||||
it
|
it.fir.delegatedWrapperData?.wrapped?.symbol!! as S
|
||||||
|
else -> it
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
@@ -425,6 +425,11 @@ public class FirBlackBoxAgainstJavaCodegenTestGenerated extends AbstractFirBlack
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxAgainstJava/interfaces"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxAgainstJava/interfaces"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("defaultMethod.kt")
|
||||||
|
public void testDefaultMethod() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxAgainstJava/interfaces/defaultMethod.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inheritJavaInterface.kt")
|
@TestMetadata("inheritJavaInterface.kt")
|
||||||
public void testInheritJavaInterface() throws Exception {
|
public void testInheritJavaInterface() throws Exception {
|
||||||
runTest("compiler/testData/codegen/boxAgainstJava/interfaces/inheritJavaInterface.kt");
|
runTest("compiler/testData/codegen/boxAgainstJava/interfaces/inheritJavaInterface.kt");
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// JVM_TARGET: 1.8
|
||||||
|
|
||||||
|
// FILE: A.java
|
||||||
|
|
||||||
|
public interface A {
|
||||||
|
default String getMessage() {
|
||||||
|
return "OK";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 1.kt
|
||||||
|
|
||||||
|
interface I : A
|
||||||
|
|
||||||
|
class B : A
|
||||||
|
|
||||||
|
open class C(a : A) : I, A by a
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val a = B()
|
||||||
|
return C(a).message
|
||||||
|
}
|
||||||
Generated
+5
@@ -424,6 +424,11 @@ public class BlackBoxAgainstJavaCodegenTestGenerated extends AbstractBlackBoxAga
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxAgainstJava/interfaces"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxAgainstJava/interfaces"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("defaultMethod.kt")
|
||||||
|
public void testDefaultMethod() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxAgainstJava/interfaces/defaultMethod.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inheritJavaInterface.kt")
|
@TestMetadata("inheritJavaInterface.kt")
|
||||||
public void testInheritJavaInterface() throws Exception {
|
public void testInheritJavaInterface() throws Exception {
|
||||||
runTest("compiler/testData/codegen/boxAgainstJava/interfaces/inheritJavaInterface.kt");
|
runTest("compiler/testData/codegen/boxAgainstJava/interfaces/inheritJavaInterface.kt");
|
||||||
|
|||||||
Generated
+5
@@ -425,6 +425,11 @@ public class IrBlackBoxAgainstJavaCodegenTestGenerated extends AbstractIrBlackBo
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxAgainstJava/interfaces"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxAgainstJava/interfaces"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("defaultMethod.kt")
|
||||||
|
public void testDefaultMethod() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxAgainstJava/interfaces/defaultMethod.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inheritJavaInterface.kt")
|
@TestMetadata("inheritJavaInterface.kt")
|
||||||
public void testInheritJavaInterface() throws Exception {
|
public void testInheritJavaInterface() throws Exception {
|
||||||
runTest("compiler/testData/codegen/boxAgainstJava/interfaces/inheritJavaInterface.kt");
|
runTest("compiler/testData/codegen/boxAgainstJava/interfaces/inheritJavaInterface.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user