Change to star projection no longer applied for functional types #KT-13715 Fixed
Also EA-87648 Fixed
This commit is contained in:
@@ -38,6 +38,7 @@ class ChangeToStarProjectionFix(element: KtTypeElement) : KotlinQuickFixAction<K
|
|||||||
val typeReference = diagnostic.psiElement.getNonStrictParentOfType<KtBinaryExpressionWithTypeRHS>()?.right
|
val typeReference = diagnostic.psiElement.getNonStrictParentOfType<KtBinaryExpressionWithTypeRHS>()?.right
|
||||||
?: diagnostic.psiElement.getNonStrictParentOfType<KtTypeReference>()
|
?: diagnostic.psiElement.getNonStrictParentOfType<KtTypeReference>()
|
||||||
val typeElement = typeReference?.typeElement ?: return null
|
val typeElement = typeReference?.typeElement ?: return null
|
||||||
|
if (typeElement is KtFunctionType) return null
|
||||||
if (typeElement.typeArgumentsAsTypes.isNotEmpty()) {
|
if (typeElement.typeArgumentsAsTypes.isNotEmpty()) {
|
||||||
return ChangeToStarProjectionFix(typeElement)
|
return ChangeToStarProjectionFix(typeElement)
|
||||||
}
|
}
|
||||||
|
|||||||
+9
@@ -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);
|
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")
|
@TestMetadata("changeToStarProjection.kt")
|
||||||
public void testChangeToStarProjection() throws Exception {
|
public void testChangeToStarProjection() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addStarProjections/cast/changeToStarProjection.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addStarProjections/cast/changeToStarProjection.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user