Do not count callable reference as recursive property access

So #KT-20104 Fixed
This commit is contained in:
Mikhail Glukhikh
2017-09-18 16:02:06 +03:00
committed by Mikhail Glukhikh
parent 8f9ea3e08b
commit 426a54c3ab
2 changed files with 9 additions and 0 deletions
@@ -95,6 +95,7 @@ class RecursivePropertyAccessorInspection : AbstractKotlinInspection() {
if (element !is KtSimpleNameExpression) return false
val propertyAccessor = element.getParentOfType<KtDeclarationWithBody>(true) as? KtPropertyAccessor ?: return false
if (element.text != propertyAccessor.property.name) return false
if (element.parent is KtCallableReferenceExpression) return false
val bindingContext = element.analyze()
val target = bindingContext[REFERENCE_TARGET, element]
if (target != bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, propertyAccessor.property]) return false
@@ -112,6 +113,7 @@ class RecursivePropertyAccessorInspection : AbstractKotlinInspection() {
val isGetter = name == "get$referencedName"
val isSetter = name == "set$referencedName"
if (!isGetter && !isSetter) return false
if (element.parent is KtCallableReferenceExpression) return false
val bindingContext = element.analyze()
val syntheticDescriptor = bindingContext[REFERENCE_TARGET, element] as? SyntheticJavaPropertyDescriptor ?: return false
val namedFunctionDescriptor = bindingContext[DECLARATION_TO_DESCRIPTOR, namedFunction]
@@ -0,0 +1,7 @@
// See KT-20104
interface Logger
fun logger(f: () -> Logger): Logger = object : Logger {}
val logger: Logger get() = logger(::logger)