Kapt3: Fix "Parameter names are clashing in inner class constructor" (KT-14998)
This commit is contained in:
committed by
Yan Zhulanow
parent
b9a0a4f3db
commit
77153f0926
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.stubs
|
||||
|
||||
import org.jetbrains.kotlin.kapt3.util.isAbstract
|
||||
import org.jetbrains.kotlin.kapt3.util.isEnum
|
||||
import org.jetbrains.kotlin.kapt3.util.isStatic
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
@@ -45,8 +46,14 @@ internal fun MethodNode.getParametersInfo(containingClass: ClassNode): List<Para
|
||||
val parameterInfos = ArrayList<ParameterInfo>(parameterTypes.size - startParameterIndex)
|
||||
for (index in startParameterIndex..parameterTypes.lastIndex) {
|
||||
val type = parameterTypes[index]
|
||||
var name = parameters.getOrNull(index - startParameterIndex)?.name
|
||||
?: localVariables.getOrNull(index + (if (isStatic) 0 else 1))?.name
|
||||
|
||||
// Use parameters only in case of the abstract methods (it hasn't local variables table)
|
||||
var name: String? = if (isAbstract(this.access) && this.name != "<init>")
|
||||
parameters.getOrNull(index - startParameterIndex)?.name
|
||||
else
|
||||
null
|
||||
|
||||
name = name ?: localVariables.getOrNull(index + (if (isStatic) 0 else 1))?.name
|
||||
?: "p${index - startParameterIndex}"
|
||||
|
||||
// Property setters has bad parameter names
|
||||
|
||||
+6
@@ -126,6 +126,12 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt14998.kt")
|
||||
public void testKt14998() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("plugins/kapt3/testData/converter/kt14998.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("modifiers.kt")
|
||||
public void testModifiers() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("plugins/kapt3/testData/converter/modifiers.kt");
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class Outer {
|
||||
private inner class Inner(val foo: String, val bar: String)
|
||||
private class Nested(val foo: String, val bar: String)
|
||||
|
||||
fun nonAbstract(s: String, i: Int) {
|
||||
|
||||
}
|
||||
|
||||
abstract fun abstract(s: String, i: Int)
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
public final class Outer {
|
||||
|
||||
public final void nonAbstract(java.lang.String s, int i) {
|
||||
}
|
||||
|
||||
public abstract void abstract(java.lang.String s, int i);
|
||||
|
||||
public Outer() {
|
||||
super();
|
||||
}
|
||||
|
||||
private final class Inner {
|
||||
private final java.lang.String foo = null;
|
||||
private final java.lang.String bar = null;
|
||||
|
||||
public final java.lang.String getFoo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final java.lang.String getBar() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Inner(java.lang.String foo, java.lang.String bar) {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
private static final class Nested {
|
||||
private final java.lang.String foo = null;
|
||||
private final java.lang.String bar = null;
|
||||
|
||||
public final java.lang.String getFoo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final java.lang.String getBar() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Nested(java.lang.String foo, java.lang.String bar) {
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user