From 7960561c4ba8d6487d39d4558e2f78fa346dd0de Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Thu, 7 Apr 2016 17:59:23 +0300 Subject: [PATCH] Minor. Use SAM-constructor to overcome overload ambiguity There is an ambiguity since 'forEach' method appeared at Iterable, that is supertype of Query --- .../kotlin/idea/intentions/SimplifyForIntention.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/SimplifyForIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/SimplifyForIntention.kt index b84e39e8b7c..18d88292dca 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/SimplifyForIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/SimplifyForIntention.kt @@ -20,6 +20,7 @@ import com.intellij.openapi.editor.Editor import com.intellij.openapi.util.TextRange import com.intellij.psi.PsiReference import com.intellij.psi.search.searches.ReferencesSearch +import com.intellij.util.Processor import com.intellij.util.Query import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor @@ -122,7 +123,8 @@ class SimplifyForIntention : SelfTargetingRangeIntention( process: (Int, KtProperty) -> Unit, cancel: () -> Unit ) { - forEach { + // TODO: Remove SAM-constructor when KT-11265 will be fixed + forEach(Processor forEach@{ val applicableUsage = getDataIfUsageIsApplicable(it, context) if (applicableUsage != null) { val (property, descriptor) = applicableUsage @@ -138,7 +140,7 @@ class SimplifyForIntention : SelfTargetingRangeIntention( cancel() return@forEach false - } + }) } private fun Query.iterateOverDataClassPropertiesUsagesWithIndex( @@ -149,7 +151,7 @@ class SimplifyForIntention : SelfTargetingRangeIntention( ) { val valueParameters = dataClass.unsubstitutedPrimaryConstructor?.valueParameters ?: return - forEach { + forEach(Processor forEach@{ val applicableUsage = getDataIfUsageIsApplicable(it, context) if (applicableUsage != null) { val (property, descriptor) = applicableUsage @@ -163,7 +165,7 @@ class SimplifyForIntention : SelfTargetingRangeIntention( cancel() return@forEach false - } + }) } private fun getDataIfUsageIsApplicable(usage: PsiReference, context: BindingContext): UsageData? {