[KAPT] Support type annotations in K2 KAPT. Fixes KT-64479

This commit is contained in:
strangepleasures
2024-01-15 10:24:38 +00:00
committed by Space Team
parent 7e9d6e601d
commit 0dd3abba2a
6 changed files with 197 additions and 7 deletions
@@ -392,7 +392,7 @@ private class StubGenerator(
print(method.name, "(")
method.parameterList.parameters.forEachIndexed{ index, parameter ->
if (index > 0) print(", ")
printTypeSignature(parameter.type)
printTypeSignature(parameter.type, false)
}
print(")")
}
@@ -430,14 +430,11 @@ private class StubGenerator(
private fun Printer.printType(type: PsiType) {
recordErrorTypes(type)
type.annotations.forEach {
printAnnotation(it, false)
}
printTypeSignature(type)
printTypeSignature(type, true)
}
private fun Printer.printTypeSignature(type: PsiType) {
printWithNoIndent((if (type is PsiClassType && isErroneous(type)) type.rawType() else type).canonicalText.replace('$', '.'))
private fun Printer.printTypeSignature(type: PsiType, annotated: Boolean) {
printWithNoIndent((if (type is PsiClassType && isErroneous(type)) type.rawType() else type).getCanonicalText(annotated).replace('$', '.'))
}
private fun Printer.printTypeParams(typeParameters: Array<PsiTypeParameter>) {
@@ -715,6 +715,12 @@ public class KotlinKapt4ContextTestGenerated extends AbstractKotlinKapt4ContextT
runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/topLevel.kt");
}
@Test
@TestMetadata("typeAnnotations.kt")
public void testTypeAnnotations() throws Exception {
runTest("plugins/kapt4/../kapt3/kapt3-compiler/testData/converter/typeAnnotations.kt");
}
@Test
@TestMetadata("unresolvedDelegateExpression.kt")
public void testUnresolvedDelegateExpression() throws Exception {