diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java index f9b35847729..25b92ce0b9a 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java @@ -813,27 +813,37 @@ public abstract class MemberCodegen; } - public static boolean isStaticAccessor(@NotNull CallableMemberDescriptor descriptor) { + public static boolean isStaticAccessor(@Nullable CallableMemberDescriptor descriptor) { if (descriptor instanceof AccessorForConstructorDescriptor) return false; return isAccessor(descriptor); } diff --git a/compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt b/compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt new file mode 100644 index 00000000000..9a97980a5a6 --- /dev/null +++ b/compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt @@ -0,0 +1,20 @@ +fun box(): String { + A.Nested().nestedA() + A.Nested().Inner().innerA() + A.companionA() + return "OK" +} + +class A private constructor(val x: T, val y: Int = 0) { + class Nested { + fun nestedA() = A(1L) + + inner class Inner { + fun innerA() = A(1L) + } + } + + companion object { + fun companionA() = A(1L) + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethod.kt b/compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethod.kt new file mode 100644 index 00000000000..a5ffca91336 --- /dev/null +++ b/compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethod.kt @@ -0,0 +1,29 @@ +// FILE: test.kt +import b.B + +fun box() = + B().getOK() + +// FILE: a.kt +package a + +open class A { + protected fun getO(x: T) = "O" + protected fun getK(x: T) = "K" +} + +// FILE: b.kt +package b + +import a.A + +class B : A() { + inner class Inner { + fun innerGetO() = getO(0L) + } + + fun lambdaGetK() = { -> getK(0L) } + + fun getOK() = + Inner().innerGetO() + lambdaGetK().invoke() +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethodWithDefaults.kt b/compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethodWithDefaults.kt new file mode 100644 index 00000000000..943d7e681cd --- /dev/null +++ b/compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethodWithDefaults.kt @@ -0,0 +1,29 @@ +// FILE: test.kt +import b.B + +fun box() = + B().getOK() + +// FILE: a.kt +package a + +open class A { + protected fun getO(x: T, z: String = "") = "O" + z + protected fun getK(x: T, z: String = "") = "K" + z +} + +// FILE: b.kt +package b + +import a.A + +class B : A() { + inner class Inner { + fun innerGetO() = getO(0L) + } + + fun lambdaGetK() = { -> getK(0L) } + + fun getOK() = + Inner().innerGetO() + lambdaGetK().invoke() +} \ No newline at end of file diff --git a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 78a92cd8495..bc9a65fc5f7 100644 --- a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -18967,6 +18967,24 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class SyntheticAccessors extends AbstractIrBlackBoxCodegenTest { + @TestMetadata("accessorForGenericConstructor.kt") + public void testAccessorForGenericConstructor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt"); + doTest(fileName); + } + + @TestMetadata("accessorForGenericMethod.kt") + public void testAccessorForGenericMethod() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethod.kt"); + doTest(fileName); + } + + @TestMetadata("accessorForGenericMethodWithDefaults.kt") + public void testAccessorForGenericMethodWithDefaults() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethodWithDefaults.kt"); + doTest(fileName); + } + @TestMetadata("accessorForProtected.kt") public void testAccessorForProtected() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForProtected.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 70f29ac434a..30b4d0112c6 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -18967,6 +18967,24 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class SyntheticAccessors extends AbstractBlackBoxCodegenTest { + @TestMetadata("accessorForGenericConstructor.kt") + public void testAccessorForGenericConstructor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt"); + doTest(fileName); + } + + @TestMetadata("accessorForGenericMethod.kt") + public void testAccessorForGenericMethod() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethod.kt"); + doTest(fileName); + } + + @TestMetadata("accessorForGenericMethodWithDefaults.kt") + public void testAccessorForGenericMethodWithDefaults() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethodWithDefaults.kt"); + doTest(fileName); + } + @TestMetadata("accessorForProtected.kt") public void testAccessorForProtected() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForProtected.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 3effa38f59f..8510ee1169f 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -18967,6 +18967,24 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class SyntheticAccessors extends AbstractLightAnalysisModeTest { + @TestMetadata("accessorForGenericConstructor.kt") + public void testAccessorForGenericConstructor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt"); + doTest(fileName); + } + + @TestMetadata("accessorForGenericMethod.kt") + public void testAccessorForGenericMethod() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethod.kt"); + doTest(fileName); + } + + @TestMetadata("accessorForGenericMethodWithDefaults.kt") + public void testAccessorForGenericMethodWithDefaults() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethodWithDefaults.kt"); + doTest(fileName); + } + @TestMetadata("accessorForProtected.kt") public void testAccessorForProtected() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForProtected.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index f32ad268026..240799a4fe4 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -22849,6 +22849,24 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class SyntheticAccessors extends AbstractJsCodegenBoxTest { + @TestMetadata("accessorForGenericConstructor.kt") + public void testAccessorForGenericConstructor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt"); + doTest(fileName); + } + + @TestMetadata("accessorForGenericMethod.kt") + public void testAccessorForGenericMethod() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethod.kt"); + doTest(fileName); + } + + @TestMetadata("accessorForGenericMethodWithDefaults.kt") + public void testAccessorForGenericMethodWithDefaults() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethodWithDefaults.kt"); + doTest(fileName); + } + @TestMetadata("accessorForProtected.kt") public void testAccessorForProtected() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForProtected.kt");