Optimize SyntheticJavaPropertyDescriptor.Companion::findByGetterOrSetter

Do not force getContributedDescriptors call when we need to request
at most three names
This commit is contained in:
Denis Zharkov
2018-07-03 15:37:53 +03:00
parent 5e6a3673c8
commit 2d50ad82a5
@@ -58,8 +58,21 @@ interface SyntheticJavaPropertyDescriptor : PropertyDescriptor {
val classDescriptorOwner = getterOrSetter.containingDeclaration as? ClassDescriptor ?: return null
val originalGetterOrSetter = getterOrSetter.original
return syntheticScopes.collectSyntheticExtensionProperties(listOf(classDescriptorOwner.defaultType))
.filterIsInstance<SyntheticJavaPropertyDescriptor>()
val names = listOfNotNull(
propertyNameByGetMethodName(name),
propertyNameBySetMethodName(name, withIsPrefix = true),
propertyNameBySetMethodName(name, withIsPrefix = false)
)
return names
.flatMap {
syntheticScopes.collectSyntheticExtensionProperties(
listOf(classDescriptorOwner.defaultType),
it,
NoLookupLocation.FROM_SYNTHETIC_SCOPE
)
}.filterIsInstance<SyntheticJavaPropertyDescriptor>()
.firstOrNull { originalGetterOrSetter == it.getMethod || originalGetterOrSetter == it.setMethod }
}