Fix wrong assumptions in quickfix

Diagnostic is always reported on overriden property

 #EA-64407 Fixed
This commit is contained in:
Denis Zharkov
2015-06-02 10:15:24 +03:00
parent 349d5f02ea
commit 11290ae9e7
4 changed files with 30 additions and 2 deletions
@@ -137,8 +137,8 @@ public class ChangeVariableTypeFix extends JetIntentionAction<JetVariableDeclara
protected List<IntentionAction> doCreateActions(@NotNull Diagnostic diagnostic) {
List<IntentionAction> actions = new LinkedList<IntentionAction>();
JetProperty property = QuickFixUtil.getParentElementOfType(diagnostic, JetProperty.class);
if (property != null) {
if (diagnostic.getPsiElement() instanceof JetProperty) {
JetProperty property = (JetProperty) diagnostic.getPsiElement();
BindingContext context = ResolvePackage.analyzeFully(property.getContainingJetFile());
JetType lowerBoundOfOverriddenPropertiesTypes = QuickFixUtil.findLowerBoundOfOverriddenCallablesReturnTypes(context, property);
@@ -0,0 +1,11 @@
// "Change 'foo' function return type to 'Boolean'" "true"
interface A {
fun foo(): Boolean
}
fun foo() {
val x = object : A {
override fun foo(): Boolean?<caret> = true
}
}
@@ -0,0 +1,11 @@
// "Change 'foo' function return type to 'Boolean'" "true"
interface A {
fun foo(): Boolean
}
fun foo() {
val x = object : A {
override fun foo(): Boolean = true
}
}
@@ -4769,6 +4769,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
doTest(fileName);
}
@TestMetadata("namedFunctionReturnOverrideInsideVariableInitializer.kt")
public void testNamedFunctionReturnOverrideInsideVariableInitializer() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/override/typeMismatchOnOverride/namedFunctionReturnOverrideInsideVariableInitializer.kt");
doTest(fileName);
}
@TestMetadata("objectInsideBody.kt")
public void testObjectInsideBody() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/override/typeMismatchOnOverride/objectInsideBody.kt");