Kapt: handle special names correctly
Parameter names of some methods are different in JVM IR, for example extension receivers of property `$annotations` methods are named `<this>`, which made the `Name.identifier` call fail. It seems fine to use the "p + index" name for this instead. #KT-49682
This commit is contained in:
+2
-6
@@ -25,7 +25,6 @@ import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.tree.AnnotationNode
|
||||
import org.jetbrains.org.objectweb.asm.tree.ClassNode
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodNode
|
||||
import java.util.*
|
||||
|
||||
internal class ParameterInfo(
|
||||
val flags: Long,
|
||||
@@ -71,11 +70,8 @@ internal fun MethodNode.getParametersInfo(
|
||||
|
||||
// @JvmOverloads constructors and ordinary methods don't have "this" local variable
|
||||
name = name ?: localVariables.getOrNull(index + localVariableIndexOffset)?.name
|
||||
?: originalDescriptor.valueParameters.getOrNull(index)?.name?.identifier
|
||||
?: "p${index - startParameterIndex}"
|
||||
|
||||
// Property setters has bad parameter names
|
||||
if (name.startsWith("<") && name.endsWith(">")) {
|
||||
?: originalDescriptor.valueParameters.getOrNull(index)?.name?.identifierOrNullIfSpecial
|
||||
if (name == null || name.startsWith("<") && name.endsWith(">")) {
|
||||
name = "p${index - startParameterIndex}"
|
||||
}
|
||||
|
||||
|
||||
@@ -27,19 +27,19 @@ public final class AnnotationsTest {
|
||||
@Anno(value = "top-level-fun")
|
||||
public static final void topLevelFun(@org.jetbrains.annotations.NotNull()
|
||||
@Anno(value = "top-level-fun-receiver")
|
||||
java.lang.String $this$topLevelFun) {
|
||||
java.lang.String p0) {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static final java.lang.String getTopLevelVal(@Anno(value = "top-level-val-receiver")
|
||||
int p0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Anno(value = "top-level-val")
|
||||
@java.lang.Deprecated()
|
||||
public static void getTopLevelVal$annotations(int p0) {
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static final java.lang.String getTopLevelVal(@Anno(value = "top-level-val-receiver")
|
||||
int $this$topLevelVal) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_STDLIB
|
||||
|
||||
// FILE: lib/Prop.java
|
||||
|
||||
Reference in New Issue
Block a user