Skip to content

Commit

Permalink
Handle explicit JvmName
Browse files Browse the repository at this point in the history
(cherry picked from commit 6ed123e)
  • Loading branch information
ting-yuan authored and KSP Auto Pick committed Sep 3, 2024
1 parent ebf987b commit c30c83e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -505,15 +505,23 @@ class ResolverAAImpl(
if (accessor.receiver.closestClassDeclaration()?.classKind == ClassKind.ANNOTATION_CLASS) {
return accessor.receiver.simpleName.asString()
}

val symbol: KaPropertyAccessorSymbol? = when (accessor) {
is KSPropertyAccessorImpl -> accessor.ktPropertyAccessorSymbol
else -> null
}

symbol?.explictJvmName()?.let {
return it
}

val prefix = if (accessor is KSPropertyGetter) {
"get"
} else {
"set"
}
val inlineSuffix = when (accessor) {
is KSPropertyAccessorImpl -> accessor.ktPropertyAccessorSymbol.inlineSuffix
else -> ""
}

val inlineSuffix = symbol?.inlineSuffix ?: ""
val mangledName = if (accessor.modifiers.contains(Modifier.INTERNAL)) {
"\$${ktModule.name}"
} else ""
Expand All @@ -529,10 +537,17 @@ class ResolverAAImpl(
}?.let {
return it.name
}
val inlineSuffix = when (declaration) {
is KSFunctionDeclarationImpl -> declaration.ktFunctionSymbol.inlineSuffix
else -> ""

val symbol: KaFunctionSymbol? = when (declaration) {
is KSFunctionDeclarationImpl -> declaration.ktFunctionSymbol
else -> null
}

symbol?.explictJvmName()?.let {
return it
}

val inlineSuffix = symbol?.inlineSuffix ?: ""
val mangledName = if (declaration.modifiers.contains(Modifier.INTERNAL)) {
"\$${ktModule.name}"
} else ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ internal val KaFunctionSymbol.inlineSuffix: String
valueParameters.map { it.returnType },
returnType,
analyze {
returnType.requiresMangling() && isKotlin && this@inlineSuffix.containingSymbol is KaClassSymbol
returnType.requiresMangling() && isKotlin && containingDeclaration != null
}
)

Expand All @@ -975,7 +975,16 @@ internal val KaPropertyAccessorSymbol.inlineSuffix: String
mangleInlineSuffix(
emptyList(),
returnType,
returnType.requiresMangling() && isKotlin
analyze {
returnType.requiresMangling() && isKotlin && containingDeclaration?.containingDeclaration != null
}
)
is KaPropertySetterSymbol -> mangleInlineSuffix(listOf(parameter.returnType), null, false)
}

private val jvmNameClassId = ClassId.fromString("kotlin/jvm/JvmName")
internal fun KaCallableSymbol.explictJvmName(): String? {
return annotations.singleOrNull() {
it.classId == jvmNameClassId
}?.arguments?.single()?.expression?.toValue() as? String
}

0 comments on commit c30c83e

Please sign in to comment.