From 79f318b2378c6539db508b2cc25c6130697ce280 Mon Sep 17 00:00:00 2001 From: Kuan-Ying Chou Date: Wed, 18 Sep 2024 21:21:25 +0100 Subject: [PATCH] Test Resolver.mapToJvmSignature() --- kotlin-analysis-api/testData/signatureMapper.kt | 6 +++++- .../devtools/ksp/processor/MapSignatureProcessor.kt | 10 ++++++++++ test-utils/testData/api/signatureMapper.kt | 6 +++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/kotlin-analysis-api/testData/signatureMapper.kt b/kotlin-analysis-api/testData/signatureMapper.kt index 386d146666..a6e2411542 100644 --- a/kotlin-analysis-api/testData/signatureMapper.kt +++ b/kotlin-analysis-api/testData/signatureMapper.kt @@ -21,6 +21,7 @@ // a: I // foo: ()Ljava/lang/String; // f: ()I +// g: ()I // : ()V // LJavaIntefaceWithVoid; // getVoid: ()Ljava/lang/Void; @@ -47,7 +48,10 @@ class Cls { fun foo(): String { return "1" } - fun f(): MyInlineClass = 1 + @JvmName("f") + fun f(): MyInlineClass = TODO() + + fun g(): MyInlineClass = TODO() } // FILE: JavaIntefaceWithVoid.java diff --git a/test-utils/src/main/kotlin/com/google/devtools/ksp/processor/MapSignatureProcessor.kt b/test-utils/src/main/kotlin/com/google/devtools/ksp/processor/MapSignatureProcessor.kt index bc7824758e..ad08878d5f 100644 --- a/test-utils/src/main/kotlin/com/google/devtools/ksp/processor/MapSignatureProcessor.kt +++ b/test-utils/src/main/kotlin/com/google/devtools/ksp/processor/MapSignatureProcessor.kt @@ -21,6 +21,7 @@ import com.google.devtools.ksp.KspExperimental import com.google.devtools.ksp.getClassDeclarationByName import com.google.devtools.ksp.processing.Resolver import com.google.devtools.ksp.symbol.KSAnnotated +import com.google.devtools.ksp.symbol.KSFunctionDeclaration @KspExperimental class MapSignatureProcessor : AbstractTestProcessor() { @@ -37,7 +38,16 @@ class MapSignatureProcessor : AbstractTestProcessor() { }.forEach { subject -> result.add(resolver.mapToJvmSignature(subject)!!) subject.declarations.forEach { + if (it is KSFunctionDeclaration) { + val decl = it.returnType!!.resolve().declaration + println("before: ${it.simpleName.asString()}: ${resolver.mapToJvmSignature(decl)}") + } result.add(it.simpleName.asString() + ": " + resolver.mapToJvmSignature(it)) + if (it is KSFunctionDeclaration) { + val decl = it.returnType!!.resolve().declaration + println("after: ${it.simpleName.asString()}: ${resolver.mapToJvmSignature(decl)}") + } + } } return emptyList() diff --git a/test-utils/testData/api/signatureMapper.kt b/test-utils/testData/api/signatureMapper.kt index 0168a62a07..07af9f770b 100644 --- a/test-utils/testData/api/signatureMapper.kt +++ b/test-utils/testData/api/signatureMapper.kt @@ -21,6 +21,7 @@ // a: I // foo: ()Ljava/lang/String; // f: ()I +// g: ()I // : ()V // LJavaIntefaceWithVoid; // getVoid: ()Ljava/lang/Void; @@ -47,7 +48,10 @@ class Cls { fun foo(): String { return "1" } - fun f(): MyInlineClass = 1 + @JvmName("f") + fun f(): MyInlineClass = TODO() + + fun g(): MyInlineClass = TODO() } // FILE: JavaIntefaceWithVoid.java