incompatible types quickfix: reregister for variable initializer (IDEA-138023)

This commit is contained in:
Anna Kozlova
2015-03-23 17:57:15 +01:00
parent d1467d1f6c
commit 4d079801bf
3 changed files with 17 additions and 5 deletions
@@ -479,6 +479,7 @@ public class HighlightUtil extends HighlightUtilBase {
HighlightInfo highlightInfo = checkAssignability(lType, rType, initializer, new TextRange(start, end), 0);
if (highlightInfo != null) {
registerChangeVariableTypeFixes(variable, rType, variable.getInitializer(), highlightInfo);
registerChangeVariableTypeFixes(initializer, lType, null, highlightInfo);
}
return highlightInfo;
}
@@ -2731,11 +2732,6 @@ public class HighlightUtil extends HighlightUtilBase {
QuickFixAction.registerQuickFixAction(highlightInfo, PriorityActionWrapper
.lowPriority(method, QUICK_FIX_FACTORY.createMethodReturnFix(method, parameter.getType(), true)));
}
} else if (expr instanceof PsiReferenceExpression) {
final PsiElement resolve = ((PsiReferenceExpression)expr).resolve();
if (resolve instanceof PsiVariable) {
registerChangeVariableTypeFixes((PsiVariable)resolve, parameter.getType(), null, highlightInfo);
}
}
}
@@ -0,0 +1,8 @@
// "Change field 'foo' type to 'java.lang.String[]'" "true"
class Base {
private String[] foo;
public void bar(String... args) {
foo = args;
}
}
@@ -0,0 +1,8 @@
// "Change field 'foo' type to 'java.lang.String[]'" "true"
class Base {
private String foo;
public void bar(String... args) {
foo<caret> = args;
}
}