You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mangled names for internal functions are incorrect when the class is present in an Android application or library module. Specifically, Resolver.getJvmName is returning a name that does not match what the Kotlin compiler generated.
Looks like there's already a downstream issue in Dagger: google/dagger#4493
Environment
KSP: 2.1.0-Beta2-1.0.26 with KSP2
Kotlin: 2.1.0-Beta2
AGP: 8.7.1
Gradle: 8.10
Context
Consider the following code for an Android Library module :library:
package dev.jonamireh
class TestClass {
internal fun mangled() {
}
}
The actual generated JVM method name for mangled is mangled$library even though the Kotlin compiler generated mangled$library_debug
JVM Modules
For the same code in a Kotlin JVM module named :jvm will be correct, with both the Kotlin compiler and KSP generating mangled$jvm.
Potential Cause
As a part of #1847, an API was added to retrieve the module name for mangled internal members. This PR also changed how the module name is fed to KSP to match what's expected for JVM modules. However, I think the previous version worked for Android modules. Obviously, KSP needs to handle each module type differently
Sample project
Here's a sample project where :processor will print the JVM name according to getJvmName for each internal function. You can test out what KSP thinks the mangled should be with:
Summary
Mangled names for internal functions are incorrect when the class is present in an Android application or library module. Specifically,
Resolver.getJvmName
is returning a name that does not match what the Kotlin compiler generated.Looks like there's already a downstream issue in Dagger: google/dagger#4493
Environment
KSP: 2.1.0-Beta2-1.0.26 with KSP2
Kotlin: 2.1.0-Beta2
AGP: 8.7.1
Gradle: 8.10
Context
Consider the following code for an Android Library module
:library
:The actual generated JVM method name for
mangled
ismangled$library
even though the Kotlin compiler generatedmangled$library_debug
JVM Modules
For the same code in a Kotlin JVM module named
:jvm
will be correct, with both the Kotlin compiler and KSP generatingmangled$jvm
.Potential Cause
As a part of #1847, an API was added to retrieve the module name for mangled internal members. This PR also changed how the module name is fed to KSP to match what's expected for JVM modules. However, I think the previous version worked for Android modules. Obviously, KSP needs to handle each module type differently
Sample project
Here's a sample project where
:processor
will print the JVM name according togetJvmName
for each internal function. You can test out what KSP thinks the mangled should be with:You can swap out
:library
for:app
or:jvm
to see the result in Android application and Kotlin JVM modules, respectively as wellThe text was updated successfully, but these errors were encountered: