[FIR Java] Hide function in scope in case it's an accessor by fact
#KT-42116 Fixed
This commit is contained in:
+16
-3
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.util.capitalizeDecapitalize.capitalizeFirstWord
|
||||
@NoMutableState
|
||||
object FirJavaSyntheticNamesProvider : FirSyntheticNamesProvider() {
|
||||
private const val GETTER_PREFIX = "get"
|
||||
private const val SETTER_PREFIX = "set"
|
||||
private const val IS_PREFIX = "is"
|
||||
|
||||
override fun possibleGetterNamesByPropertyName(name: Name): List<Name> {
|
||||
@@ -34,11 +35,23 @@ object FirJavaSyntheticNamesProvider : FirSyntheticNamesProvider() {
|
||||
override fun setterNameByGetterName(name: Name): Name {
|
||||
val identifier = name.identifier
|
||||
val prefix = when {
|
||||
identifier.startsWith("get") -> "get"
|
||||
identifier.startsWith("is") -> "is"
|
||||
identifier.startsWith(GETTER_PREFIX) -> GETTER_PREFIX
|
||||
identifier.startsWith(IS_PREFIX) -> IS_PREFIX
|
||||
else -> throw IllegalArgumentException()
|
||||
}
|
||||
return Name.identifier("set" + identifier.removePrefix(prefix))
|
||||
return Name.identifier(SETTER_PREFIX + identifier.removePrefix(prefix))
|
||||
}
|
||||
|
||||
override fun propertyNameByAccessorName(name: Name): Name? {
|
||||
if (name.isSpecial) return null
|
||||
val identifier = name.identifier
|
||||
val prefix = when {
|
||||
identifier.startsWith(GETTER_PREFIX) -> GETTER_PREFIX
|
||||
identifier.startsWith(IS_PREFIX) -> ""
|
||||
identifier.startsWith(SETTER_PREFIX) -> SETTER_PREFIX
|
||||
else -> return null
|
||||
}
|
||||
return Name.identifier(identifier.removePrefix(prefix).decapitalize())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user