Make change signature fix non-applicable for constructors (EA-76554)

This commit is contained in:
Nikolay Krasko
2016-01-26 19:09:52 +03:00
parent 8331442661
commit 7c8a5b0b83
3 changed files with 18 additions and 1 deletions
@@ -102,7 +102,9 @@ public class ChangeFunctionReturnTypeFix extends KotlinQuickFixAction<KtFunction
@Override
public boolean isAvailable(@NotNull Project project, @Nullable Editor editor, @NotNull PsiFile file) {
return super.isAvailable(project, editor, file) && !ErrorUtils.containsErrorType(type);
return super.isAvailable(project, editor, file) &&
!ErrorUtils.containsErrorType(type) &&
!(getElement() instanceof KtConstructor);
}
@Override
@@ -0,0 +1,9 @@
// "Change 'A' function return type to 'B'" "false"
// ACTION: Change 'b' type to 'A'
// ACTION: Convert property initializer to getter
// ERROR: Type mismatch: inferred type is A but B was expected
class A constructor() {}
interface B
val b: B = <caret>A()
@@ -7274,6 +7274,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
doTest(fileName);
}
@TestMetadata("notApplicableToConstructor.kt")
public void testNotApplicableToConstructor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/notApplicableToConstructor.kt");
doTest(fileName);
}
@TestMetadata("propertyGetterInitializerTypeMismatch.kt")
public void testPropertyGetterInitializerTypeMismatch() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/typeMismatchOnReturnedExpression/propertyGetterInitializerTypeMismatch.kt");