Skip to content

Commit

Permalink
Test Resolver.mapToJvmSignature()
Browse files Browse the repository at this point in the history
  • Loading branch information
kuanyingchou authored and ting-yuan committed Oct 3, 2024
1 parent 20e6324 commit 79f318b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
6 changes: 5 additions & 1 deletion kotlin-analysis-api/testData/signatureMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// a: I
// foo: ()Ljava/lang/String;
// f: ()I
// g: ()I
// <init>: ()V
// LJavaIntefaceWithVoid;
// getVoid: ()Ljava/lang/Void;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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()
Expand Down
6 changes: 5 additions & 1 deletion test-utils/testData/api/signatureMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// a: I
// foo: ()Ljava/lang/String;
// f: ()I
// g: ()I
// <init>: ()V
// LJavaIntefaceWithVoid;
// getVoid: ()Ljava/lang/Void;
Expand All @@ -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
Expand Down

0 comments on commit 79f318b

Please sign in to comment.