Fix shortening references for receiver in MakeTypeExplicitInLambdaIntention
#KT-5474 Fixed
This commit is contained in:
@@ -71,6 +71,10 @@ public class JetPsiFactory(private val project: Project) {
|
||||
return createType("T<X, Y>").findElementAt(3)!!
|
||||
}
|
||||
|
||||
public fun createDot(): PsiElement {
|
||||
return createType("T.(X)").findElementAt(1)!!
|
||||
}
|
||||
|
||||
public fun createColon(): PsiElement {
|
||||
return createProperty("val x: Int").findElementAt(5)!!
|
||||
}
|
||||
|
||||
@@ -97,10 +97,9 @@ public class MakeTypeExplicitInLambdaIntention : JetSelfTargetingIntention<JetFu
|
||||
val expectedReceiverType = func.getReceiverParameter()?.getType()
|
||||
if (hasImplicitReceiverType(element) && expectedReceiverType != null) {
|
||||
val receiverTypeString = DescriptorRenderer.SOURCE_CODE.renderType(expectedReceiverType)
|
||||
val paramListString = functionLiteral.getValueParameterList()?.getText()
|
||||
val paramListWithReceiver = psiFactory.createExpression(receiverTypeString + "." + paramListString)
|
||||
ShortenReferences.process(paramListWithReceiver)
|
||||
functionLiteral.getValueParameterList()?.replace(paramListWithReceiver)
|
||||
val dot = functionLiteral.addBefore(psiFactory.createDot(), functionLiteral.getValueParameterList())
|
||||
functionLiteral.addBefore(psiFactory.createType(receiverTypeString), dot)
|
||||
ShortenReferences.process(functionLiteral.getReceiverTypeRef()!!)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
fun main() {
|
||||
val randomFunction: kotlin.Array<kotlin.Int>.(x: Int) -> Boolean = {<caret>y -> if (this[0] < y) true else false}
|
||||
val randomFunction: kotlin.support.AbstractIterator<kotlin.Int>.(x: Int) -> Boolean = {<caret>y -> if (this.next() < y) true else false}
|
||||
}
|
||||
|
||||
// WITH_RUNTIME
|
||||
+5
-1
@@ -1,3 +1,7 @@
|
||||
import kotlin.support.AbstractIterator
|
||||
|
||||
fun main() {
|
||||
val randomFunction: kotlin.Array<kotlin.Int>.(x: Int) -> Boolean = { Array<Int>.(y: Int): Boolean -> if (this[0] < y) true else false}
|
||||
val randomFunction: kotlin.support.AbstractIterator<kotlin.Int>.(x: Int) -> Boolean = { AbstractIterator<Int>.(y: Int): Boolean -> if (this.next() < y) true else false}
|
||||
}
|
||||
|
||||
// WITH_RUNTIME
|
||||
Reference in New Issue
Block a user