diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirBlackBoxCodegenBasedTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirBlackBoxCodegenBasedTestGenerated.java index c0227fbdede..59f998748ee 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirBlackBoxCodegenBasedTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirBlackBoxCodegenBasedTestGenerated.java @@ -30529,6 +30529,12 @@ public class LLFirBlackBoxCodegenBasedTestGenerated extends AbstractLLFirBlackBo @TestMetadata("compiler/testData/codegen/box/javaInterop") @TestDataPath("$PROJECT_ROOT") public class JavaInterop { + @Test + @TestMetadata("abstractMethodsOfAny.kt") + public void testAbstractMethodsOfAny() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/abstractMethodsOfAny.kt"); + } + @Test public void testAllFilesPresentInJavaInterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaInterop"), Pattern.compile("^(.+)\\.kt$"), null, true); diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirReversedBlackBoxCodegenBasedTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirReversedBlackBoxCodegenBasedTestGenerated.java index 27ac679aede..b00536f314d 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirReversedBlackBoxCodegenBasedTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirReversedBlackBoxCodegenBasedTestGenerated.java @@ -30529,6 +30529,12 @@ public class LLFirReversedBlackBoxCodegenBasedTestGenerated extends AbstractLLFi @TestMetadata("compiler/testData/codegen/box/javaInterop") @TestDataPath("$PROJECT_ROOT") public class JavaInterop { + @Test + @TestMetadata("abstractMethodsOfAny.kt") + public void testAbstractMethodsOfAny() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/abstractMethodsOfAny.kt"); + } + @Test public void testAllFilesPresentInJavaInterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaInterop"), Pattern.compile("^(.+)\\.kt$"), null, true); diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyClass.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyClass.kt index 0834646ace7..c3f33bfb82f 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyClass.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyClass.kt @@ -16,7 +16,6 @@ import org.jetbrains.kotlin.fir.isSubstitutionOrIntersectionOverride import org.jetbrains.kotlin.fir.scopes.FirContainingNamesAwareScope import org.jetbrains.kotlin.fir.scopes.processClassifiersByName import org.jetbrains.kotlin.fir.symbols.impl.FirFieldSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI import org.jetbrains.kotlin.ir.declarations.* @@ -197,7 +196,6 @@ class Fir2IrLazyClass( symbol.isSubstitutionOrIntersectionOverride -> {} !shouldBuildStub(symbol.fir) -> {} symbol.containingClassLookupTag() != ownerLookupTag -> {} - symbol.isAbstractMethodOfAny() -> {} else -> { // Lazy declarations are created together with their symbol, so it's safe to take the owner here @OptIn(UnsafeDuringIrConstructionAPI::class) @@ -260,11 +258,6 @@ class Fir2IrLazyClass( override val isNewPlaceForBodyGeneration: Boolean get() = fir.isNewPlaceForBodyGeneration == true - private fun FirNamedFunctionSymbol.isAbstractMethodOfAny(): Boolean { - if (modality != Modality.ABSTRACT) return false - return isMethodOfAny - } - private var irLoaded: Boolean? = null override fun loadIr(): Boolean { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java index d938ce01ee8..7aee1aa575d 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java @@ -30134,6 +30134,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr @TestMetadata("compiler/testData/codegen/box/javaInterop") @TestDataPath("$PROJECT_ROOT") public class JavaInterop { + @Test + @TestMetadata("abstractMethodsOfAny.kt") + public void testAbstractMethodsOfAny() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/abstractMethodsOfAny.kt"); + } + @Test public void testAllFilesPresentInJavaInterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaInterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java index 10cb0bc1abe..ac7f54b6538 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java @@ -30134,6 +30134,12 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated @TestMetadata("compiler/testData/codegen/box/javaInterop") @TestDataPath("$PROJECT_ROOT") public class JavaInterop { + @Test + @TestMetadata("abstractMethodsOfAny.kt") + public void testAbstractMethodsOfAny() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/abstractMethodsOfAny.kt"); + } + @Test public void testAllFilesPresentInJavaInterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaInterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java index 664644166b1..5901c1af966 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java @@ -30134,6 +30134,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo @TestMetadata("compiler/testData/codegen/box/javaInterop") @TestDataPath("$PROJECT_ROOT") public class JavaInterop { + @Test + @TestMetadata("abstractMethodsOfAny.kt") + public void testAbstractMethodsOfAny() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/abstractMethodsOfAny.kt"); + } + @Test public void testAllFilesPresentInJavaInterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaInterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); diff --git a/compiler/testData/codegen/box/javaInterop/abstractMethodsOfAny.kt b/compiler/testData/codegen/box/javaInterop/abstractMethodsOfAny.kt new file mode 100644 index 00000000000..e520d163181 --- /dev/null +++ b/compiler/testData/codegen/box/javaInterop/abstractMethodsOfAny.kt @@ -0,0 +1,63 @@ +// TARGET_BACKEND: JVM +// FILE: JI.java +public interface JI { + @Override + public abstract boolean equals(Object o); + @Override + public abstract int hashCode(); + @Override + public abstract String toString(); +} + +// FILE: JC.java +public abstract class JC { + @Override + public abstract boolean equals(Object o); + @Override + public abstract int hashCode(); + @Override + public abstract String toString(); +} + +// FILE: JC2.java +public abstract class JC2 extends JC { +} + +// FILE: box.kt + +interface KI : JI +class X : KI { + override fun equals(other: Any?): Boolean = true + override fun hashCode(): Int = 0 + override fun toString(): String = "" +} + +abstract class KC : JC() +class Y : KC() { + override fun equals(other: Any?): Boolean = true + override fun hashCode(): Int = 0 + override fun toString(): String = "" +} + +abstract class KC2 : JC2() +class Z : KC2() { + override fun equals(other: Any?): Boolean = true + override fun hashCode(): Int = 0 + override fun toString(): String = "" +} + +fun box(): String { + X().equals(X()) + X().hashCode() + X().toString() + + Y().equals(Y()) + Y().hashCode() + Y().toString() + + Z().equals(Z()) + Z().hashCode() + Z().toString() + + return "OK" +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 273cb978ca5..cc6f8812067 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -28436,6 +28436,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { @TestMetadata("compiler/testData/codegen/box/javaInterop") @TestDataPath("$PROJECT_ROOT") public class JavaInterop { + @Test + @TestMetadata("abstractMethodsOfAny.kt") + public void testAbstractMethodsOfAny() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/abstractMethodsOfAny.kt"); + } + @Test public void testAllFilesPresentInJavaInterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaInterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index ba935def780..3578c8f41c2 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -30134,6 +30134,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes @TestMetadata("compiler/testData/codegen/box/javaInterop") @TestDataPath("$PROJECT_ROOT") public class JavaInterop { + @Test + @TestMetadata("abstractMethodsOfAny.kt") + public void testAbstractMethodsOfAny() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/abstractMethodsOfAny.kt"); + } + @Test public void testAllFilesPresentInJavaInterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaInterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java index 4b3d58c1ecc..dc5b3959c39 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java @@ -30134,6 +30134,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack @TestMetadata("compiler/testData/codegen/box/javaInterop") @TestDataPath("$PROJECT_ROOT") public class JavaInterop { + @Test + @TestMetadata("abstractMethodsOfAny.kt") + public void testAbstractMethodsOfAny() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/abstractMethodsOfAny.kt"); + } + @Test public void testAllFilesPresentInJavaInterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaInterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 66740ff6286..a0a293e6d8f 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -25501,6 +25501,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); } + @TestMetadata("abstractMethodsOfAny.kt") + public void testAbstractMethodsOfAny() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/abstractMethodsOfAny.kt"); + } + public void testAllFilesPresentInJavaInterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaInterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); }