diff --git a/idea/src/org/jetbrains/jet/plugin/intentions/InsertExplicitTypeArguments.kt b/idea/src/org/jetbrains/jet/plugin/intentions/InsertExplicitTypeArguments.kt index 86b69d7881a..ad85bac1fb2 100644 --- a/idea/src/org/jetbrains/jet/plugin/intentions/InsertExplicitTypeArguments.kt +++ b/idea/src/org/jetbrains/jet/plugin/intentions/InsertExplicitTypeArguments.kt @@ -58,17 +58,13 @@ public class InsertExplicitTypeArguments : JetSelfTargetingIntention") + DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(args[it]!!) + }.joinToString(", ", "<", ">") - val name = element.getCalleeExpression()?.getText() - if (name == null) return + val callee = element.getCalleeExpression() + if (callee == null) return - val valueAndFunctionArguments = element.getText()?.substring(name.size) ?: throw AssertionError("InsertExplicitTypeArguments intention shouldn't be applicable for empty call expression") - val expr = psiFactory.createExpression("$name$typeArgs${valueAndFunctionArguments}") - element.replace(expr) + element.addAfter(psiFactory.createTypeArguments(typeArgs), callee) + ShortenReferences.process(element.getTypeArgumentList()!!) } } \ No newline at end of file diff --git a/idea/testData/intentions/insertExplicitTypeArguments/insertImportForArg.kt b/idea/testData/intentions/insertExplicitTypeArguments/insertImportForArg.kt new file mode 100644 index 00000000000..10e3f0aff50 --- /dev/null +++ b/idea/testData/intentions/insertExplicitTypeArguments/insertImportForArg.kt @@ -0,0 +1,7 @@ +fun foo(c: kotlin.support.AbstractIterator>) { + bar(c) +} + +fun bar(t: T): T = t + +// WITH_RUNTIME \ No newline at end of file diff --git a/idea/testData/intentions/insertExplicitTypeArguments/insertImportForArg.kt.after b/idea/testData/intentions/insertExplicitTypeArguments/insertImportForArg.kt.after new file mode 100644 index 00000000000..1e09c2b3b66 --- /dev/null +++ b/idea/testData/intentions/insertExplicitTypeArguments/insertImportForArg.kt.after @@ -0,0 +1,10 @@ +import kotlin.concurrent.FunctionalList +import kotlin.support.AbstractIterator + +fun foo(c: kotlin.support.AbstractIterator>) { + bar>>(c) +} + +fun bar(t: T): T = t + +// WITH_RUNTIME \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/plugin/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/intentions/IntentionTestGenerated.java index 4171c8f65b7..3eeb133d029 100644 --- a/idea/tests/org/jetbrains/jet/plugin/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/plugin/intentions/IntentionTestGenerated.java @@ -3304,6 +3304,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest("idea/testData/intentions/insertExplicitTypeArguments/inapplicableTypeNotInferred.kt"); } + @TestMetadata("insertImportForArg.kt") + public void testInsertImportForArg() throws Exception { + doTest("idea/testData/intentions/insertExplicitTypeArguments/insertImportForArg.kt"); + } + @TestMetadata("insertManyTypes.kt") public void testInsertManyTypes() throws Exception { doTest("idea/testData/intentions/insertExplicitTypeArguments/insertManyTypes.kt");