Fix wrong assumptions in quickfix
Diagnostic is always reported on overriden property #EA-64407 Fixed
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
+11
@@ -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
|
||||
}
|
||||
}
|
||||
+11
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user