Kapt: Handle parameter with Java names clashing with Java keywords properly (KT-18377)

This commit is contained in:
Yan Zhulanow
2017-06-28 16:43:58 +03:00
committed by Yan Zhulanow
parent e56e3d78c8
commit a983137978
5 changed files with 23 additions and 2 deletions
@@ -437,7 +437,7 @@ class ClassFileToSourceStubConverter(
info.visibleAnnotations,
info.invisibleAnnotations)
val name = treeMaker.name(getValidIdentifierName(info.name) ?: "p${index}_" + info.name.hashCode())
val name = treeMaker.name(getValidIdentifierName(info.name) ?: "p${index}_" + info.name.hashCode().ushr(1))
val type = treeMaker.Type(info.type)
treeMaker.VarDef(modifiers, name, type, null)
}
@@ -180,6 +180,12 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi
doTest(fileName);
}
@TestMetadata("kt18377.kt")
public void testKt18377() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/kapt3/testData/converter/kt18377.kt");
doTest(fileName);
}
@TestMetadata("mapEntry.kt")
public void testMapEntry() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("plugins/kapt3/testData/converter/mapEntry.kt");
+3
View File
@@ -0,0 +1,3 @@
import java.util.Date
fun Date(double: Double): Date = Date(double.times(1000).toLong())
+12
View File
@@ -0,0 +1,12 @@
@kotlin.Metadata()
public final class Kt18377Kt {
public Kt18377Kt() {
super();
}
@org.jetbrains.annotations.NotNull()
public static final java.util.Date Date(double p0_1484504552) {
return null;
}
}
+1 -1
View File
@@ -50,7 +50,7 @@ public final class Test {
public final void strangeFun4(@org.jetbrains.annotations.NotNull()
java.lang.String a, @org.jetbrains.annotations.NotNull()
java.lang.String p1_1899121793) {
java.lang.String p1_949560896) {
}
public Test() {