IR: do not assert presence of property getter in IrFakeOverrideBuilder

#KT-65456 Fixed
This commit is contained in:
Alexander Udalov
2024-01-31 23:33:15 +01:00
committed by Space Team
parent b752d3997b
commit a22c16e745
12 changed files with 88 additions and 3 deletions
@@ -50958,6 +50958,12 @@ public class LLFirBlackBoxCodegenBasedTestGenerated extends AbstractLLFirBlackBo
runTest("compiler/testData/codegen/box/sam/differentFqNames.kt");
}
@Test
@TestMetadata("fieldInJavaSamInterface.kt")
public void testFieldInJavaSamInterface() throws Exception {
runTest("compiler/testData/codegen/box/sam/fieldInJavaSamInterface.kt");
}
@Test
@TestMetadata("inlinedSamWrapper.kt")
public void testInlinedSamWrapper() throws Exception {
@@ -50958,6 +50958,12 @@ public class LLFirReversedBlackBoxCodegenBasedTestGenerated extends AbstractLLFi
runTest("compiler/testData/codegen/box/sam/differentFqNames.kt");
}
@Test
@TestMetadata("fieldInJavaSamInterface.kt")
public void testFieldInJavaSamInterface() throws Exception {
runTest("compiler/testData/codegen/box/sam/fieldInJavaSamInterface.kt");
}
@Test
@TestMetadata("inlinedSamWrapper.kt")
public void testInlinedSamWrapper() throws Exception {
@@ -50483,6 +50483,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
runTest("compiler/testData/codegen/box/sam/differentFqNames.kt");
}
@Test
@TestMetadata("fieldInJavaSamInterface.kt")
public void testFieldInJavaSamInterface() throws Exception {
runTest("compiler/testData/codegen/box/sam/fieldInJavaSamInterface.kt");
}
@Test
@TestMetadata("inlinedSamWrapper.kt")
public void testInlinedSamWrapper() throws Exception {
@@ -50483,6 +50483,12 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated
runTest("compiler/testData/codegen/box/sam/differentFqNames.kt");
}
@Test
@TestMetadata("fieldInJavaSamInterface.kt")
public void testFieldInJavaSamInterface() throws Exception {
runTest("compiler/testData/codegen/box/sam/fieldInJavaSamInterface.kt");
}
@Test
@TestMetadata("inlinedSamWrapper.kt")
public void testInlinedSamWrapper() throws Exception {
@@ -50483,6 +50483,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
runTest("compiler/testData/codegen/box/sam/differentFqNames.kt");
}
@Test
@TestMetadata("fieldInJavaSamInterface.kt")
public void testFieldInJavaSamInterface() throws Exception {
runTest("compiler/testData/codegen/box/sam/fieldInJavaSamInterface.kt");
}
@Test
@TestMetadata("inlinedSamWrapper.kt")
public void testInlinedSamWrapper() throws Exception {
@@ -46,9 +46,11 @@ class IrFakeOverrideBuilder(
is IrSimpleFunction -> this.overriddenSymbols =
value.memoryOptimizedMap { it as? IrSimpleFunctionSymbol ?: error("Unexpected function overridden symbol: $it") }
is IrProperty -> {
val overriddenProperties = value.memoryOptimizedMap { it as? IrPropertySymbol ?: error("Unexpected property overridden symbol: $it") }
val getter = this.getter ?: error("Property has no getter: ${render()}")
getter.overriddenSymbols = overriddenProperties.memoryOptimizedMap { it.owner.getter!!.symbol }
val overriddenProperties =
value.memoryOptimizedMap { it as? IrPropertySymbol ?: error("Unexpected property overridden symbol: $it") }
this.getter?.let { getter ->
getter.overriddenSymbols = overriddenProperties.memoryOptimizedMapNotNull { it.owner.getter?.symbol }
}
this.setter?.let { setter ->
setter.overriddenSymbols = overriddenProperties.memoryOptimizedMapNotNull { it.owner.setter?.symbol }
}
@@ -0,0 +1,24 @@
// TARGET_BACKEND: JVM
// SAM_CONVERSIONS: CLASS
// FILE: S.java
public interface S {
String bar(String t);
S RESULT = new S() {
@Override
public String bar(String t) { return t; }
};
}
// FILE: J.java
public class J {
public static String foo(String e, S c) {
return c.bar(e);
}
}
// FILE: box.kt
fun box(): String {
val s: (String) -> String = { S.RESULT.bar(it) }
return J.foo("OK", S(s))
}
@@ -49799,6 +49799,12 @@ public class JvmAbiConsistencyTestBoxGenerated extends AbstractJvmAbiConsistency
runTest("compiler/testData/codegen/box/sam/differentFqNames.kt");
}
@Test
@TestMetadata("fieldInJavaSamInterface.kt")
public void testFieldInJavaSamInterface() throws Exception {
runTest("compiler/testData/codegen/box/sam/fieldInJavaSamInterface.kt");
}
@Test
@TestMetadata("inlinedSamWrapper.kt")
public void testInlinedSamWrapper() throws Exception {
@@ -46769,6 +46769,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/sam/differentFqNames.kt");
}
@Test
@TestMetadata("fieldInJavaSamInterface.kt")
public void testFieldInJavaSamInterface() throws Exception {
runTest("compiler/testData/codegen/box/sam/fieldInJavaSamInterface.kt");
}
@Test
@TestMetadata("inlinedSamWrapper.kt")
public void testInlinedSamWrapper() throws Exception {
@@ -49799,6 +49799,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/sam/differentFqNames.kt");
}
@Test
@TestMetadata("fieldInJavaSamInterface.kt")
public void testFieldInJavaSamInterface() throws Exception {
runTest("compiler/testData/codegen/box/sam/fieldInJavaSamInterface.kt");
}
@Test
@TestMetadata("inlinedSamWrapper.kt")
public void testInlinedSamWrapper() throws Exception {
@@ -49799,6 +49799,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
runTest("compiler/testData/codegen/box/sam/differentFqNames.kt");
}
@Test
@TestMetadata("fieldInJavaSamInterface.kt")
public void testFieldInJavaSamInterface() throws Exception {
runTest("compiler/testData/codegen/box/sam/fieldInJavaSamInterface.kt");
}
@Test
@TestMetadata("inlinedSamWrapper.kt")
public void testInlinedSamWrapper() throws Exception {
@@ -40010,6 +40010,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/sam/differentFqNames.kt");
}
@TestMetadata("fieldInJavaSamInterface.kt")
public void testFieldInJavaSamInterface() throws Exception {
runTest("compiler/testData/codegen/box/sam/fieldInJavaSamInterface.kt");
}
@TestMetadata("inlinedSamWrapper.kt")
public void testInlinedSamWrapper() throws Exception {
runTest("compiler/testData/codegen/box/sam/inlinedSamWrapper.kt");