Fix shortening references for return type in MakeTypeExplicitInLambdaIntention

#KT-5475 Fixed
This commit is contained in:
Pavel V. Talanov
2014-07-15 18:05:58 +04:00
parent 5246735648
commit e390385bf9
4 changed files with 18 additions and 1 deletions
@@ -88,9 +88,9 @@ public class MakeTypeExplicitInLambdaIntention : JetSelfTargetingIntention<JetFu
val paramList = functionLiteral.getValueParameterList()
val returnTypeColon = psiFactory.createColon()
val returnTypeExpr = psiFactory.createType(DescriptorRenderer.SOURCE_CODE.renderType(expectedReturnType))
ShortenReferences.process(returnTypeExpr)
functionLiteral.addAfter(returnTypeExpr, paramList)
functionLiteral.addAfter(returnTypeColon, paramList)
ShortenReferences.process(functionLiteral.getReturnTypeRef()!!)
}
// Step 3: make the receiver type explicit
@@ -0,0 +1,5 @@
fun main(c: kotlin.support.AbstractIterator<Int>) {
val f = { <caret>(x: Int) -> c}
}
// WITH_RUNTIME
@@ -0,0 +1,7 @@
import kotlin.support.AbstractIterator
fun main(c: kotlin.support.AbstractIterator<Int>) {
val f = {(x: Int): AbstractIterator<Int> -> c}
}
// WITH_RUNTIME
@@ -3510,6 +3510,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
doTest("idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReceiver.kt");
}
@TestMetadata("shortenReferencesForReturnType.kt")
public void testShortenReferencesForReturnType() throws Exception {
doTest("idea/testData/intentions/makeTypeExplicitInLambda/shortenReferencesForReturnType.kt");
}
@TestMetadata("singleParam.kt")
public void testSingleParam() throws Exception {
doTest("idea/testData/intentions/makeTypeExplicitInLambda/singleParam.kt");