diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/RecursivePropertyAccessorInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/RecursivePropertyAccessorInspection.kt index 34eb740972d..1515f089c20 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/RecursivePropertyAccessorInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/RecursivePropertyAccessorInspection.kt @@ -95,6 +95,7 @@ class RecursivePropertyAccessorInspection : AbstractKotlinInspection() { if (element !is KtSimpleNameExpression) return false val propertyAccessor = element.getParentOfType(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] diff --git a/idea/testData/inspections/recursivePropertyAccessor/logger.kt b/idea/testData/inspections/recursivePropertyAccessor/logger.kt new file mode 100644 index 00000000000..b96b745ffa9 --- /dev/null +++ b/idea/testData/inspections/recursivePropertyAccessor/logger.kt @@ -0,0 +1,7 @@ +// See KT-20104 + +interface Logger + +fun logger(f: () -> Logger): Logger = object : Logger {} + +val logger: Logger get() = logger(::logger) \ No newline at end of file