mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-04-20 00:21:29 +00:00
Don't call possibleGetterNamesByPropertyName without a reason
This commit is contained in:
@@ -81,54 +81,51 @@ class JavaClassUseSiteMemberScope(
|
||||
processor: (FirVariableSymbol<*>) -> Unit
|
||||
) {
|
||||
val overrideCandidates = mutableSetOf<FirCallableSymbol<*>>()
|
||||
val klass = symbol.fir
|
||||
declaredMemberScope.processPropertiesByName(propertyName) { variableSymbol ->
|
||||
if (variableSymbol.isStatic) return@processPropertiesByName
|
||||
overrideCandidates += variableSymbol
|
||||
processor(variableSymbol)
|
||||
}
|
||||
|
||||
if (klass is FirJavaClass) {
|
||||
for (getterName in getterNames) {
|
||||
var getterSymbol: FirNamedFunctionSymbol? = null
|
||||
var setterSymbol: FirNamedFunctionSymbol? = null
|
||||
declaredMemberScope.processFunctionsByName(getterName) { functionSymbol ->
|
||||
if (getterSymbol == null) {
|
||||
val function = functionSymbol.fir
|
||||
if (!function.isStatic && function.valueParameters.isEmpty()) {
|
||||
getterSymbol = functionSymbol
|
||||
}
|
||||
for (getterName in getterNames) {
|
||||
var getterSymbol: FirNamedFunctionSymbol? = null
|
||||
var setterSymbol: FirNamedFunctionSymbol? = null
|
||||
declaredMemberScope.processFunctionsByName(getterName) { functionSymbol ->
|
||||
if (getterSymbol == null) {
|
||||
val function = functionSymbol.fir
|
||||
if (!function.isStatic && function.valueParameters.isEmpty()) {
|
||||
getterSymbol = functionSymbol
|
||||
}
|
||||
}
|
||||
val setterName = session.syntheticNamesProvider.setterNameByGetterName(getterName)
|
||||
if (getterSymbol != null && setterName != null) {
|
||||
declaredMemberScope.processFunctionsByName(setterName) { functionSymbol ->
|
||||
if (setterSymbol == null) {
|
||||
val function = functionSymbol.fir
|
||||
if (!function.isStatic && function.valueParameters.size == 1) {
|
||||
val returnTypeRef = function.returnTypeRef
|
||||
if (returnTypeRef.isUnit) {
|
||||
// Unit return type
|
||||
setterSymbol = functionSymbol
|
||||
} else if (returnTypeRef is FirJavaTypeRef) {
|
||||
// Void/void return type
|
||||
when (val returnType = returnTypeRef.type) {
|
||||
is JavaPrimitiveTypeImpl ->
|
||||
if (returnType.psi.kind == JvmPrimitiveTypeKind.VOID) {
|
||||
setterSymbol = functionSymbol
|
||||
}
|
||||
is JavaPrimitiveType ->
|
||||
if (returnType.type == null) {
|
||||
setterSymbol = functionSymbol
|
||||
}
|
||||
}
|
||||
}
|
||||
val setterName = session.syntheticNamesProvider.setterNameByGetterName(getterName)
|
||||
if (getterSymbol != null && setterName != null) {
|
||||
declaredMemberScope.processFunctionsByName(setterName) { functionSymbol ->
|
||||
if (setterSymbol == null) {
|
||||
val function = functionSymbol.fir
|
||||
if (!function.isStatic && function.valueParameters.size == 1) {
|
||||
val returnTypeRef = function.returnTypeRef
|
||||
if (returnTypeRef.isUnit) {
|
||||
// Unit return type
|
||||
setterSymbol = functionSymbol
|
||||
} else if (returnTypeRef is FirJavaTypeRef) {
|
||||
// Void/void return type
|
||||
when (val returnType = returnTypeRef.type) {
|
||||
is JavaPrimitiveTypeImpl ->
|
||||
if (returnType.psi.kind == JvmPrimitiveTypeKind.VOID) {
|
||||
setterSymbol = functionSymbol
|
||||
}
|
||||
is JavaPrimitiveType ->
|
||||
if (returnType.type == null) {
|
||||
setterSymbol = functionSymbol
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val accessorSymbol = generateAccessorSymbol(getterSymbol!!, setterSymbol, propertyName)
|
||||
overrideCandidates += accessorSymbol
|
||||
}
|
||||
val accessorSymbol = generateAccessorSymbol(getterSymbol!!, setterSymbol, propertyName)
|
||||
overrideCandidates += accessorSymbol
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,11 +141,11 @@ class JavaClassUseSiteMemberScope(
|
||||
}
|
||||
|
||||
override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) {
|
||||
// Do not generate accessors at all?
|
||||
if (name.isSpecial) {
|
||||
return processAccessorFunctionsAndPropertiesByName(name, emptyList(), processor)
|
||||
val getterNames = if (symbol.fir is FirJavaClass) {
|
||||
FirJavaSyntheticNamesProvider.possibleGetterNamesByPropertyName(name)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
val getterNames = FirJavaSyntheticNamesProvider.possibleGetterNamesByPropertyName(name)
|
||||
return processAccessorFunctionsAndPropertiesByName(name, getterNames, processor)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user