From 6e8acc64535cd84234f875606a38c6c3299a404f Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Fri, 20 Nov 2015 14:16:11 +0300 Subject: [PATCH] Psi Unifier: Do not unify parameters with block expressions --- .../kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt | 2 +- .../evaluateExpression/evalExprInWhenBranch.kt.after | 2 +- .../localClassWithSuperclassParameterInLocalFun.kt.after | 2 +- .../stringTemplates/fullEntryWithSimpleName.kt.after | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt b/idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt index 0539b523418..56ea2e8b495 100644 --- a/idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt +++ b/idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt @@ -823,7 +823,7 @@ public class KotlinPsiUnifier( if (targetElementUnwrapped == patternElementUnwrapped) return MATCHED if (targetElementUnwrapped == null || patternElementUnwrapped == null) return UNMATCHED - if (!checkEquivalence) { + if (!checkEquivalence && targetElementUnwrapped !is KtBlockExpression) { val referencedPatternDescriptor = (patternElementUnwrapped as? KtReferenceExpression)?.let { it.bindingContext[BindingContext.REFERENCE_TARGET, it] } diff --git a/idea/testData/refactoring/extractFunction/controlFlow/evaluateExpression/evalExprInWhenBranch.kt.after b/idea/testData/refactoring/extractFunction/controlFlow/evaluateExpression/evalExprInWhenBranch.kt.after index d5602f79d08..e01cae1473a 100644 --- a/idea/testData/refactoring/extractFunction/controlFlow/evaluateExpression/evalExprInWhenBranch.kt.after +++ b/idea/testData/refactoring/extractFunction/controlFlow/evaluateExpression/evalExprInWhenBranch.kt.after @@ -2,7 +2,7 @@ // PARAM_DESCRIPTOR: val b: kotlin.Int defined in foo // SIBLING: fun foo(a: Int): Int { - val b: Int = 1 + val b: Int = i(1) return when (a + b) { 0 -> i(b) 1 -> -b diff --git a/idea/testData/refactoring/extractFunction/parameters/nonDenotableTypes/localClassWithSuperclassParameterInLocalFun.kt.after b/idea/testData/refactoring/extractFunction/parameters/nonDenotableTypes/localClassWithSuperclassParameterInLocalFun.kt.after index 2dc231e3d60..c1e1b733c34 100644 --- a/idea/testData/refactoring/extractFunction/parameters/nonDenotableTypes/localClassWithSuperclassParameterInLocalFun.kt.after +++ b/idea/testData/refactoring/extractFunction/parameters/nonDenotableTypes/localClassWithSuperclassParameterInLocalFun.kt.after @@ -9,7 +9,7 @@ fun foo(): T { // SIBLING: fun bar(): T { - val a = A() + val a = a(A()) return a(a) } } \ No newline at end of file diff --git a/idea/testData/refactoring/extractFunction/stringTemplates/fullEntryWithSimpleName.kt.after b/idea/testData/refactoring/extractFunction/stringTemplates/fullEntryWithSimpleName.kt.after index d7802ccbe99..775e377bba4 100644 --- a/idea/testData/refactoring/extractFunction/stringTemplates/fullEntryWithSimpleName.kt.after +++ b/idea/testData/refactoring/extractFunction/stringTemplates/fullEntryWithSimpleName.kt.after @@ -1,8 +1,8 @@ // PARAM_DESCRIPTOR: value-parameter val a: kotlin.Int defined in foo // PARAM_TYPES: kotlin.Int, Number, Comparable, java.io.Serializable, Any fun foo(a: Int): String { - val x = "-$a" - val y = "x${a}y" + val x = "-${i(a)}" + val y = "x${i(a)}y" val z = "x$ay" return "abc${i(a)}def" }