diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/kt65399.kt b/plugins/kapt3/kapt3-compiler/testData/converter/kt65399.kt new file mode 100644 index 00000000000..41852151e0b --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/kt65399.kt @@ -0,0 +1,5 @@ +package org.jetbrains + +class C { + object `$serializer` +} \ No newline at end of file diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/kt65399.txt b/plugins/kapt3/kapt3-compiler/testData/converter/kt65399.txt new file mode 100644 index 00000000000..87f12cbf741 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/kt65399.txt @@ -0,0 +1,39 @@ +package org.jetbrains; + +/** + * public final class org/jetbrains/C : kotlin/Any { + * + * // signature: ()V + * public constructor() + * + * // nested class: $serializer + * + * // module name: main + * } + */ +@kotlin.Metadata() +public final class C { + + public C() { + super(); + } + + /** + * public final object org/jetbrains/C.$serializer : kotlin/Any { + * + * // signature: ()V + * private constructor() + * + * // module name: main + * } + */ + @kotlin.Metadata() + public static final class $serializer { + @org.jetbrains.annotations.NotNull() + public static final org.jetbrains.C.$serializer INSTANCE = null; + + private $serializer() { + super(); + } + } +} diff --git a/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/IrClassFileToSourceStubConverterTestGenerated.java b/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/IrClassFileToSourceStubConverterTestGenerated.java index 874e25872c3..d45def04495 100644 --- a/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/IrClassFileToSourceStubConverterTestGenerated.java +++ b/plugins/kapt3/kapt3-compiler/tests-gen/org/jetbrains/kotlin/kapt3/test/runners/IrClassFileToSourceStubConverterTestGenerated.java @@ -511,6 +511,12 @@ public class IrClassFileToSourceStubConverterTestGenerated extends AbstractIrCla runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt61729.kt"); } + @Test + @TestMetadata("kt65399.kt") + public void testKt65399() throws Exception { + runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt65399.kt"); + } + @Test @TestMetadata("kt65453.kt") public void testKt65453() throws Exception { diff --git a/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/StubGenerator.kt b/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/StubGenerator.kt index 72f47aaa2f4..eac15e2544b 100644 --- a/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/StubGenerator.kt +++ b/plugins/kapt4/src/org/jetbrains/kotlin/kapt4/StubGenerator.kt @@ -435,12 +435,14 @@ private class StubGenerator( } private fun Printer.printTypeSignature(type: PsiType, annotated: Boolean) { - printWithNoIndent( - (if (type is PsiClassType && isErroneous(type)) type.rawType() else type) - .getCanonicalText(annotated) - .replace('$', '.') - .replace(",", ", ") - ) + var typeToPrint = if (type is PsiEllipsisType) type.componentType else type + if (typeToPrint is PsiClassType && isErroneous(typeToPrint)) typeToPrint = typeToPrint.rawType() + val repr = typeToPrint.getCanonicalText(annotated) + .replace('$', '.') // Some mapped and marker types contain $ for some reason + .replace("..", ".$") // Fixes KT-65399 and similar issues with synthetic classes with names starting with $ + .replace(",", ", ") // Type parameters + printWithNoIndent(repr) + if (type is PsiEllipsisType) printWithNoIndent("...") } private fun Printer.printTypeParams(typeParameters: Array) { diff --git a/plugins/kapt4/tests-gen/org/jetbrains/kotlin/kapt4/KotlinKapt4ContextTestGenerated.java b/plugins/kapt4/tests-gen/org/jetbrains/kotlin/kapt4/KotlinKapt4ContextTestGenerated.java index dff5ff8f5b9..a0790ad251d 100644 --- a/plugins/kapt4/tests-gen/org/jetbrains/kotlin/kapt4/KotlinKapt4ContextTestGenerated.java +++ b/plugins/kapt4/tests-gen/org/jetbrains/kotlin/kapt4/KotlinKapt4ContextTestGenerated.java @@ -511,6 +511,12 @@ public class KotlinKapt4ContextTestGenerated extends AbstractKotlinKapt4ContextT runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/kt61729.kt"); } + @Test + @TestMetadata("kt65399.kt") + public void testKt65399() throws Exception { + runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/kt65399.kt"); + } + @Test @TestMetadata("kt65453.kt") public void testKt65453() throws Exception {