[KAPT] KT-65399 Fix rendering of types with names starting with $.
Solves a specific issue with Kotlin serialization, and most likely, similar issues with synthetic classes. Types with `$` in other positions will be still rendered incorrectly due to imprecise conversion of such types from Kotlin to Java in the analysis API. Merge-request: KT-MR-14235 Merged-by: Pavel Mikhailovskii <Pavel.Mikhailovskii@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
58264e177f
commit
d75463a7d5
@@ -0,0 +1,5 @@
|
||||
package org.jetbrains
|
||||
|
||||
class C {
|
||||
object `$serializer`
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.jetbrains;
|
||||
|
||||
/**
|
||||
* public final class org/jetbrains/C : kotlin/Any {
|
||||
*
|
||||
* // signature: <init>()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: <init>()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();
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -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 {
|
||||
|
||||
@@ -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<PsiTypeParameter>) {
|
||||
|
||||
+6
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user