Avoid excessive JavaForKotlinOverridePropertyDescriptors
When there are two candidates for a Java method to be interpreted as a getter for inherited Kotlin property, one from current class, another from supertype, create just one JavaForKotlinOverridePropertyDescriptor. Case in point: java.lang.Hashtable.
This commit is contained in:
+6
-2
@@ -447,11 +447,13 @@ class LazyJavaClassMemberScope(
|
|||||||
val propertiesFromSupertypes = getPropertiesFromSupertypes(name)
|
val propertiesFromSupertypes = getPropertiesFromSupertypes(name)
|
||||||
if (propertiesFromSupertypes.isEmpty()) return
|
if (propertiesFromSupertypes.isEmpty()) return
|
||||||
|
|
||||||
|
val handledProperties = SmartSet.create<PropertyDescriptor>()
|
||||||
|
|
||||||
val propertiesOverridesFromSuperTypes = SmartSet.create<PropertyDescriptor>()
|
val propertiesOverridesFromSuperTypes = SmartSet.create<PropertyDescriptor>()
|
||||||
|
|
||||||
addPropertyOverrideByMethod(propertiesFromSupertypes, result) { searchMethodsByNameWithoutBuiltinMagic(it) }
|
addPropertyOverrideByMethod(propertiesFromSupertypes, result, handledProperties) { searchMethodsByNameWithoutBuiltinMagic(it) }
|
||||||
|
|
||||||
addPropertyOverrideByMethod(propertiesFromSupertypes, propertiesOverridesFromSuperTypes) {
|
addPropertyOverrideByMethod(propertiesFromSupertypes - handledProperties, propertiesOverridesFromSuperTypes, null) {
|
||||||
searchMethodsInSupertypesWithoutBuiltinMagic(it)
|
searchMethodsInSupertypesWithoutBuiltinMagic(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,12 +472,14 @@ class LazyJavaClassMemberScope(
|
|||||||
private fun addPropertyOverrideByMethod(
|
private fun addPropertyOverrideByMethod(
|
||||||
propertiesFromSupertypes: Set<PropertyDescriptor>,
|
propertiesFromSupertypes: Set<PropertyDescriptor>,
|
||||||
result: MutableCollection<PropertyDescriptor>,
|
result: MutableCollection<PropertyDescriptor>,
|
||||||
|
handledProperties: MutableSet<PropertyDescriptor>?,
|
||||||
functions: (Name) -> Collection<SimpleFunctionDescriptor>
|
functions: (Name) -> Collection<SimpleFunctionDescriptor>
|
||||||
) {
|
) {
|
||||||
for (property in propertiesFromSupertypes) {
|
for (property in propertiesFromSupertypes) {
|
||||||
val newProperty = createPropertyDescriptorByMethods(property, functions)
|
val newProperty = createPropertyDescriptorByMethods(property, functions)
|
||||||
if (newProperty != null) {
|
if (newProperty != null) {
|
||||||
result.add(newProperty)
|
result.add(newProperty)
|
||||||
|
handledProperties?.add(property)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user