Do not count callable reference as recursive property access
So #KT-20104 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
8f9ea3e08b
commit
426a54c3ab
@@ -95,6 +95,7 @@ class RecursivePropertyAccessorInspection : AbstractKotlinInspection() {
|
|||||||
if (element !is KtSimpleNameExpression) return false
|
if (element !is KtSimpleNameExpression) return false
|
||||||
val propertyAccessor = element.getParentOfType<KtDeclarationWithBody>(true) as? KtPropertyAccessor ?: return false
|
val propertyAccessor = element.getParentOfType<KtDeclarationWithBody>(true) as? KtPropertyAccessor ?: return false
|
||||||
if (element.text != propertyAccessor.property.name) return false
|
if (element.text != propertyAccessor.property.name) return false
|
||||||
|
if (element.parent is KtCallableReferenceExpression) return false
|
||||||
val bindingContext = element.analyze()
|
val bindingContext = element.analyze()
|
||||||
val target = bindingContext[REFERENCE_TARGET, element]
|
val target = bindingContext[REFERENCE_TARGET, element]
|
||||||
if (target != bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, propertyAccessor.property]) return false
|
if (target != bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, propertyAccessor.property]) return false
|
||||||
@@ -112,6 +113,7 @@ class RecursivePropertyAccessorInspection : AbstractKotlinInspection() {
|
|||||||
val isGetter = name == "get$referencedName"
|
val isGetter = name == "get$referencedName"
|
||||||
val isSetter = name == "set$referencedName"
|
val isSetter = name == "set$referencedName"
|
||||||
if (!isGetter && !isSetter) return false
|
if (!isGetter && !isSetter) return false
|
||||||
|
if (element.parent is KtCallableReferenceExpression) return false
|
||||||
val bindingContext = element.analyze()
|
val bindingContext = element.analyze()
|
||||||
val syntheticDescriptor = bindingContext[REFERENCE_TARGET, element] as? SyntheticJavaPropertyDescriptor ?: return false
|
val syntheticDescriptor = bindingContext[REFERENCE_TARGET, element] as? SyntheticJavaPropertyDescriptor ?: return false
|
||||||
val namedFunctionDescriptor = bindingContext[DECLARATION_TO_DESCRIPTOR, namedFunction]
|
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)
|
||||||
Reference in New Issue
Block a user