mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
add type cast intention for poly expressions (IDEA-188731)
inference errors on poly expressions are not propagated to the expected type (variable declaration, return statement, etc) like for standalone expressions: dedicated intentions should be registered
This commit is contained in:
+8
@@ -889,6 +889,14 @@ public class HighlightMethodUtil {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, QUICK_FIX_FACTORY.createSurroundWithArrayFix(methodCall, null));
|
||||
QualifyThisArgumentFix.registerQuickFixAction(methodCandidates, methodCall, highlightInfo, fixRange);
|
||||
|
||||
PsiType expectedTypeByParent = PsiTypesUtil.getExpectedTypeByParent(methodCall);
|
||||
if (expectedTypeByParent != null) {
|
||||
PsiType methodCallType = methodCall.getType();
|
||||
if (methodCallType != null && TypeConversionUtil.areTypesConvertible(methodCallType, expectedTypeByParent)) {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createAddTypeCastFix(expectedTypeByParent, methodCall));
|
||||
}
|
||||
}
|
||||
|
||||
CandidateInfo[] candidates = resolveHelper.getReferencedMethodCandidates(methodCall, true);
|
||||
ChangeStringLiteralToCharInMethodCallFix.registerFixes(candidates, methodCall, highlightInfo);
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Cast to 'B'" "true"
|
||||
import java.util.*;
|
||||
|
||||
class A { }
|
||||
|
||||
class B extends A {
|
||||
public B getStrings() {
|
||||
return (B) getFirstItem(new ArrayList<A>());
|
||||
}
|
||||
|
||||
public static <T> T getFirstItem(Set<T> items) { return null; }
|
||||
public static <T> T getFirstItem(List<T> items) { return null; }
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Cast to 'B'" "true"
|
||||
import java.util.*;
|
||||
|
||||
class A { }
|
||||
|
||||
class B extends A {
|
||||
public B getStrings() {
|
||||
return get<caret>FirstItem(new ArrayList<A>());
|
||||
}
|
||||
|
||||
public static <T> T getFirstItem(Set<T> items) { return null; }
|
||||
public static <T> T getFirstItem(List<T> items) { return null; }
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Cast to 'B'" "false"
|
||||
import java.util.*;
|
||||
|
||||
class A { }
|
||||
|
||||
class B extends A {
|
||||
public B getStrings() {
|
||||
return get<caret>FirstItem(new ArrayList<A>());
|
||||
}
|
||||
|
||||
public static <T> T getFirstItem(Set<T> items) { return null; }
|
||||
public static <T> ArrayList<T> getFirstItem(List<T> items) { return null; }
|
||||
}
|
||||
Reference in New Issue
Block a user