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
JVM names for Kotlin property getters & setters are incorrect when the Kotlin property name starts with "is". Specifically, Resolver.getJvmName is returning a name that does not match what the Kotlin compiler generated.
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:
package dev.jonamireh
interface TestInterface {
var isOpen: String
}
For the property getter of isOpen, Resolver.getJvmName() is returning getIsOpen even though the Kotlin compiler generated isOpen.
For the property setter of isOpen, Resolver.getJvmName() is returning setIsOpen even though the Kotlin compiler generated setOpen.
If the name of the property starts with is, a different name mapping rule is used: the name of the getter will be the same as the property name, and the name of the setter will be obtained by replacing is with set. For example, for a property isOpen, the getter will be called isOpen() and the setter will be called setOpen(). This rule applies for properties of any type, not just Boolean.
Sample project
Here's a sample project where :processor will print the JVM name according to getJvmName for each property getter & setter. You can test out what KSP thinks the getter/setter should be with:
The text was updated successfully, but these errors were encountered:
jonamireh
changed the title
[KSP2] JVM names for property getters/setters are incorrect when they start with "is"
[KSP2] JVM names for property getters/setters are incorrect if they start with "is"
Oct 30, 2024
Summary
JVM names for Kotlin property getters & setters are incorrect when the Kotlin property name starts with "is". Specifically,
Resolver.getJvmName
is returning a name that does not match what the Kotlin compiler generated.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:
isOpen
,Resolver.getJvmName()
is returninggetIsOpen
even though the Kotlin compiler generatedisOpen
.isOpen
,Resolver.getJvmName()
is returningsetIsOpen
even though the Kotlin compiler generatedsetOpen
.This permuation is documented in the Kotlin documentation for Calling Kotlin from Java:
Sample project
Here's a sample project where
:processor
will print the JVM name according togetJvmName
for each property getter & setter. You can test out what KSP thinks the getter/setter should be with:The text was updated successfully, but these errors were encountered: