Skip to content

Commit

Permalink
Test jvmSignature for inline classes
Browse files Browse the repository at this point in the history
  • Loading branch information
kuanyingchou committed Apr 26, 2024
1 parent c262051 commit 0c0f733
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Expand Up @@ -17,15 +17,23 @@

package com.google.devtools.ksp.processor

import com.google.devtools.ksp.KspExperimental
import com.google.devtools.ksp.getClassDeclarationByName
import com.google.devtools.ksp.getDeclaredFunctions
import com.google.devtools.ksp.processing.Resolver
import com.google.devtools.ksp.symbol.*
import com.google.devtools.ksp.visitor.KSTopDownVisitor

open class ClassKindsProcessor : AbstractTestProcessor() {
val results = mutableListOf<String>()

@OptIn(KspExperimental::class)
override fun process(resolver: Resolver): List<KSAnnotated> {
resolver.getClassDeclarationByName("MyTest")!!.let { cls ->
cls.getDeclaredFunctions().single { it.simpleName.asString() == "f" }.let { f ->
println(resolver.mapToJvmSignature(f.returnType!!.resolve().declaration))
}
}
fun KSClassDeclaration.pretty(): String = "${qualifiedName!!.asString()}: $classKind"
val files = resolver.getNewFiles()
files.forEach {
Expand Down
4 changes: 4 additions & 0 deletions test-utils/testData/api/classKinds.kt
Expand Up @@ -38,6 +38,10 @@
// END

// FILE: K.kt
@JvmInline value class MyInlineClass(val value: Int)
class MyTest {
fun f(): MyInlineClass
}
class KC
interface KI
annotation class KA
Expand Down

0 comments on commit 0c0f733

Please sign in to comment.