Skip to content

Commit

Permalink
Expand inline classes before mapping to jvm types
Browse files Browse the repository at this point in the history
by requesting AA to do so implicitly.
  • Loading branch information
ting-yuan committed Oct 3, 2024
1 parent 79f318b commit 0aff910
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -759,17 +759,10 @@ class ResolverAAImpl(
return if (this is KSTypeImpl) {
analyze {
val decl = (this@toSignature.declaration as? KSClassDeclaration)
// special handling for single parameter inline value class
// unwrap the underlying for jvm signature.
if (
decl != null &&
(decl.modifiers.contains(Modifier.INLINE) || decl.modifiers.contains(Modifier.VALUE)) &&
decl.primaryConstructor?.parameters?.size == 1
) {
decl.primaryConstructor!!.parameters.single().type.resolve().toSignature()
} else {
this@toSignature.type.toSignature()
}
// Force inline value class to be unwrapped.
// Do not remove until AA fixes this.
decl?.primaryConstructor
type.toSignature()
}
} else {
"<ERROR>"
Expand All @@ -778,7 +771,7 @@ class ResolverAAImpl(

return when (ksAnnotated) {
is KSClassDeclaration -> analyze {
(ksAnnotated.asStarProjectedType() as KSTypeImpl).type.mapToJvmType().descriptor
(ksAnnotated.asStarProjectedType() as KSTypeImpl).toSignature()
}
is KSFunctionDeclarationImpl -> {
analyze {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ class MapSignatureProcessor : AbstractTestProcessor() {
}.forEach { subject ->
result.add(resolver.mapToJvmSignature(subject)!!)
subject.declarations.forEach {
var returnTypeSignature: String? = null
if (it is KSFunctionDeclaration) {
val decl = it.returnType!!.resolve().declaration
println("before: ${it.simpleName.asString()}: ${resolver.mapToJvmSignature(decl)}")
returnTypeSignature = 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)}")
assert(returnTypeSignature == resolver.mapToJvmSignature(decl))
}

}
}
return emptyList()
Expand Down

0 comments on commit 0aff910

Please sign in to comment.