[FIR] Fix lookup order for statics in super chains
The order was reversed and the static in the top-most class in the inheritance hierarchy would be found instead of the lowest one.
This commit is contained in:
committed by
Mikhail Glukhikh
parent
4ec369ac5b
commit
593fb8770b
+6
@@ -35588,6 +35588,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/statics/protectedStaticAndInline.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleStaticInJavaSuperChain.kt")
|
||||
public void testSimpleStaticInJavaSuperChain() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/statics/simpleStaticInJavaSuperChain.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("syntheticAccessor.kt")
|
||||
public void testSyntheticAccessor() throws Exception {
|
||||
|
||||
@@ -180,7 +180,7 @@ fun SessionHolder.collectImplicitReceivers(
|
||||
throw IllegalArgumentException("Incorrect label & receiver owner: ${owner.javaClass}")
|
||||
}
|
||||
}
|
||||
return ImplicitReceivers(implicitReceiverValue, implicitCompanionValues.asReversed())
|
||||
return ImplicitReceivers(implicitReceiverValue, implicitCompanionValues)
|
||||
}
|
||||
|
||||
fun SessionHolder.collectTowerDataElementsForClass(owner: FirClass<*>, defaultType: ConeKotlinType): TowerElementsForClass {
|
||||
@@ -221,8 +221,8 @@ fun SessionHolder.collectTowerDataElementsForClass(owner: FirClass<*>, defaultTy
|
||||
owner.staticScope(this),
|
||||
companionReceiver,
|
||||
companionObject?.staticScope(this),
|
||||
superClassesStaticsAndCompanionReceivers,
|
||||
allImplicitCompanionValues
|
||||
superClassesStaticsAndCompanionReceivers.asReversed(),
|
||||
allImplicitCompanionValues.asReversed()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -234,6 +234,8 @@ class TowerElementsForClass(
|
||||
val staticScope: FirScope?,
|
||||
val companionReceiver: ImplicitReceiverValue<*>?,
|
||||
val companionStaticScope: FirScope?,
|
||||
// Ordered from inner scopes to outer scopes.
|
||||
val superClassesStaticsAndCompanionReceivers: List<FirTowerDataElement>,
|
||||
// Ordered from inner scopes to outer scopes.
|
||||
val implicitCompanionValues: List<ImplicitReceiverValue<*>>
|
||||
)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// FILE: Base.java
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// FILE: A.java
|
||||
|
||||
public class A {
|
||||
public static String s = "A.s: NOT OK";
|
||||
public static String f() {
|
||||
return "A.f: NOT OK";
|
||||
}
|
||||
|
||||
public static class B extends A {
|
||||
public static String s = "OK";
|
||||
public static String f() {
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: Kotlin.kt
|
||||
|
||||
class Kotlin: A.B() {
|
||||
fun getS() = s
|
||||
fun callF() = f()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val kotlin = Kotlin()
|
||||
if (kotlin.getS() != "OK") return "fail1"
|
||||
return kotlin.callF()
|
||||
}
|
||||
+6
@@ -35788,6 +35788,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/statics/protectedStaticAndInline.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleStaticInJavaSuperChain.kt")
|
||||
public void testSimpleStaticInJavaSuperChain() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/statics/simpleStaticInJavaSuperChain.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("syntheticAccessor.kt")
|
||||
public void testSyntheticAccessor() throws Exception {
|
||||
|
||||
+6
@@ -35588,6 +35588,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/statics/protectedStaticAndInline.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleStaticInJavaSuperChain.kt")
|
||||
public void testSimpleStaticInJavaSuperChain() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/statics/simpleStaticInJavaSuperChain.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("syntheticAccessor.kt")
|
||||
public void testSyntheticAccessor() throws Exception {
|
||||
|
||||
+5
@@ -29277,6 +29277,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/statics/protectedStaticAndInline.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleStaticInJavaSuperChain.kt")
|
||||
public void testSimpleStaticInJavaSuperChain() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/statics/simpleStaticInJavaSuperChain.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("syntheticAccessor.kt")
|
||||
public void testSyntheticAccessor() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/statics/syntheticAccessor.kt");
|
||||
|
||||
Reference in New Issue
Block a user