[KAPT] Take function argument names from original descriptor
#KT-43804 Fixed
This commit is contained in:
+1
-1
@@ -913,7 +913,7 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
||||
val asmReturnType = Type.getReturnType(method.desc)
|
||||
val jcReturnType = if (isConstructor) null else treeMaker.Type(asmReturnType)
|
||||
|
||||
val parametersInfo = method.getParametersInfo(containingClass, isInner)
|
||||
val parametersInfo = method.getParametersInfo(containingClass, isInner, descriptor)
|
||||
|
||||
if (!checkIfValidTypeName(containingClass, asmReturnType)
|
||||
|| parametersInfo.any { !checkIfValidTypeName(containingClass, it.type) }
|
||||
|
||||
+8
-3
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.stubs
|
||||
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.kapt3.util.isAbstract
|
||||
import org.jetbrains.kotlin.kapt3.util.isEnum
|
||||
import org.jetbrains.kotlin.kapt3.util.isJvmOverloadsGenerated
|
||||
@@ -35,7 +35,11 @@ internal class ParameterInfo(
|
||||
val invisibleAnnotations: List<AnnotationNode>?
|
||||
)
|
||||
|
||||
internal fun MethodNode.getParametersInfo(containingClass: ClassNode, isInnerClassMember: Boolean): List<ParameterInfo> {
|
||||
internal fun MethodNode.getParametersInfo(
|
||||
containingClass: ClassNode,
|
||||
isInnerClassMember: Boolean,
|
||||
originalDescriptor: CallableDescriptor
|
||||
): List<ParameterInfo> {
|
||||
val localVariables = this.localVariables ?: emptyList()
|
||||
val parameters = this.parameters ?: emptyList()
|
||||
val isStatic = isStatic(access)
|
||||
@@ -67,6 +71,7 @@ internal fun MethodNode.getParametersInfo(containingClass: ClassNode, isInnerCla
|
||||
|
||||
// @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
|
||||
@@ -80,4 +85,4 @@ internal fun MethodNode.getParametersInfo(containingClass: ClassNode, isInnerCla
|
||||
parameterInfos += ParameterInfo(0, name, type, visibleAnnotations, invisibleAnnotations)
|
||||
}
|
||||
return parameterInfos
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -474,6 +474,11 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/stripMetadata.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendArgName.kt")
|
||||
public void testSuspendArgName() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/suspendArgName.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendErrorTypes.kt")
|
||||
public void testSuspendErrorTypes() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/suspendErrorTypes.kt");
|
||||
|
||||
+5
@@ -475,6 +475,11 @@ public class IrClassFileToSourceStubConverterTestGenerated extends AbstractIrCla
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/stripMetadata.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendArgName.kt")
|
||||
public void testSuspendArgName() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/suspendArgName.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendErrorTypes.kt")
|
||||
public void testSuspendErrorTypes() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/suspendErrorTypes.kt");
|
||||
|
||||
@@ -17,7 +17,7 @@ public final class User {
|
||||
|
||||
@java.lang.Override()
|
||||
public boolean equals(@org.jetbrains.annotations.Nullable()
|
||||
java.lang.Object p0) {
|
||||
java.lang.Object other) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ public final class ClassWithParent implements java.lang.CharSequence {
|
||||
}
|
||||
|
||||
@java.lang.Override()
|
||||
public final char charAt(int p0) {
|
||||
public final char charAt(int index) {
|
||||
return '\u0000';
|
||||
}
|
||||
|
||||
public abstract char get(int p0);
|
||||
public abstract char get(int index);
|
||||
|
||||
public abstract int getLength();
|
||||
|
||||
|
||||
+6
-6
@@ -10,32 +10,32 @@ public final class Child extends kotlin.collections.AbstractList<java.lang.Strin
|
||||
}
|
||||
|
||||
@java.lang.Override()
|
||||
public final boolean contains(java.lang.Object p0) {
|
||||
public final boolean contains(java.lang.Object element) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@java.lang.Override()
|
||||
public boolean contains(java.lang.String p0) {
|
||||
public boolean contains(java.lang.String element) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@java.lang.Override()
|
||||
public final int indexOf(java.lang.Object p0) {
|
||||
public final int indexOf(java.lang.Object element) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@java.lang.Override()
|
||||
public int indexOf(java.lang.String p0) {
|
||||
public int indexOf(java.lang.String element) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@java.lang.Override()
|
||||
public final int lastIndexOf(java.lang.Object p0) {
|
||||
public final int lastIndexOf(java.lang.Object element) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@java.lang.Override()
|
||||
public int lastIndexOf(java.lang.String p0) {
|
||||
public int lastIndexOf(java.lang.String element) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ public final class Cl {
|
||||
private final java.lang.String a = null;
|
||||
|
||||
@java.lang.Override()
|
||||
public boolean equals(java.lang.Object p0) {
|
||||
public boolean equals(java.lang.Object other) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
open class Test {
|
||||
|
||||
open fun getTestNoSuspend(text: String): String {
|
||||
return text
|
||||
}
|
||||
|
||||
open suspend fun getTest(text: String): String {
|
||||
return text
|
||||
}
|
||||
|
||||
open fun getTestNoSuspendInvalid(`te xt`: String): String {
|
||||
return `te xt`
|
||||
}
|
||||
|
||||
open suspend fun getTestInvalid(`te xt`: String): String {
|
||||
return `te xt`
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import java.lang.System;
|
||||
|
||||
@kotlin.Metadata()
|
||||
public class Test {
|
||||
|
||||
public Test() {
|
||||
super();
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public java.lang.String getTestNoSuspend(@org.jetbrains.annotations.NotNull()
|
||||
java.lang.String text) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.Nullable()
|
||||
public java.lang.Object getTest(@org.jetbrains.annotations.NotNull()
|
||||
java.lang.String text, @org.jetbrains.annotations.NotNull()
|
||||
kotlin.coroutines.Continuation<? super java.lang.String> continuation) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public java.lang.String getTestNoSuspendInvalid(@org.jetbrains.annotations.NotNull()
|
||||
java.lang.String p0_55085957) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.Nullable()
|
||||
public java.lang.Object getTestInvalid(@org.jetbrains.annotations.NotNull()
|
||||
java.lang.String p0_55085957, @org.jetbrains.annotations.NotNull()
|
||||
kotlin.coroutines.Continuation<? super java.lang.String> continuation) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ public final class Foo {
|
||||
|
||||
@org.jetbrains.annotations.Nullable()
|
||||
public final java.lang.Object a(@org.jetbrains.annotations.NotNull()
|
||||
kotlin.coroutines.Continuation<ABC> p0) {
|
||||
kotlin.coroutines.Continuation<ABC> continuation) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user