From 5246735648521ecfd0f50d8477e4ca8eb50f9c67 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Tue, 15 Jul 2014 17:47:20 +0400 Subject: [PATCH] Fix shortening references for receiver in MakeTypeExplicitInLambdaIntention #KT-5474 Fixed --- .../src/org/jetbrains/jet/lang/psi/JetPsiFactory.kt | 4 ++++ .../plugin/intentions/MakeTypeExplicitInLambdaIntention.kt | 7 +++---- .../shortenReferencesForReceiver.kt | 4 +++- .../shortenReferencesForReceiver.kt.after | 6 +++++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiFactory.kt b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiFactory.kt index d790a02a59f..1f37c794ef0 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiFactory.kt +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiFactory.kt @@ -71,6 +71,10 @@ public class JetPsiFactory(private val project: Project) { return createType("T").findElementAt(3)!! } + public fun createDot(): PsiElement { + return createType("T.(X)").findElementAt(1)!! + } + public fun createColon(): PsiElement { return createProperty("val x: Int").findElementAt(5)!! } diff --git a/idea/src/org/jetbrains/jet/plugin/intentions/MakeTypeExplicitInLambdaIntention.kt b/idea/src/org/jetbrains/jet/plugin/intentions/MakeTypeExplicitInLambdaIntention.kt index aeaf26b6494..b05020e9867 100644 --- a/idea/src/org/jetbrains/jet/plugin/intentions/MakeTypeExplicitInLambdaIntention.kt +++ b/idea/src/org/jetbrains/jet/plugin/intentions/MakeTypeExplicitInLambdaIntention.kt @@ -97,10 +97,9 @@ public class MakeTypeExplicitInLambdaIntention : JetSelfTargetingIntention.(x: Int) -> Boolean = {y -> if (this[0] < y) true else false} + val randomFunction: kotlin.support.AbstractIterator.(x: Int) -> Boolean = {y -> if (this.next() < y) true else false} } + +// WITH_RUNTIME \ No newline at end of file diff --git a/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReceiver.kt.after b/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReceiver.kt.after index 78ce2a70c15..48216e982c5 100644 --- a/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReceiver.kt.after +++ b/idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReceiver.kt.after @@ -1,3 +1,7 @@ +import kotlin.support.AbstractIterator + fun main() { - val randomFunction: kotlin.Array.(x: Int) -> Boolean = { Array.(y: Int): Boolean -> if (this[0] < y) true else false} + val randomFunction: kotlin.support.AbstractIterator.(x: Int) -> Boolean = { AbstractIterator.(y: Int): Boolean -> if (this.next() < y) true else false} } + +// WITH_RUNTIME \ No newline at end of file