Change to star projection no longer applied for functional types #KT-13715 Fixed

Also EA-87648 Fixed
This commit is contained in:
Mikhail Glukhikh
2016-09-09 10:22:24 +03:00
parent 23132ad519
commit 998399bcd8
3 changed files with 16 additions and 0 deletions
@@ -38,6 +38,7 @@ class ChangeToStarProjectionFix(element: KtTypeElement) : KotlinQuickFixAction<K
val typeReference = diagnostic.psiElement.getNonStrictParentOfType<KtBinaryExpressionWithTypeRHS>()?.right
?: diagnostic.psiElement.getNonStrictParentOfType<KtTypeReference>()
val typeElement = typeReference?.typeElement ?: return null
if (typeElement is KtFunctionType) return null
if (typeElement.typeArgumentsAsTypes.isNotEmpty()) {
return ChangeToStarProjectionFix(typeElement)
}
@@ -0,0 +1,9 @@
// "Change type arguments to <*, *>" "false"
// ACTION: Convert to expression body
class Constructor<out T>(val x: T)
fun y() : Constructor<*> = Constructor(42)
fun x(): (String) -> String {
return y() as<caret> (String) -> String
}
@@ -480,6 +480,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/addStarProjections/cast"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
}
@TestMetadata("changeFunctionalToStarProjection.kt")
public void testChangeFunctionalToStarProjection() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addStarProjections/cast/changeFunctionalToStarProjection.kt");
doTest(fileName);
}
@TestMetadata("changeToStarProjection.kt")
public void testChangeToStarProjection() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addStarProjections/cast/changeToStarProjection.kt");