[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
@@ -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