mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
explicit right to left side assignment failure when inference breaks on return type (IDEA-152677)
This commit is contained in:
+7
-1
@@ -378,6 +378,7 @@ public class InferenceSession {
|
||||
|
||||
myCheckApplicabilityPhase = false;
|
||||
if (properties != null && !properties.isApplicabilityCheck()) {
|
||||
String expectedActualErrorMessage = null;
|
||||
final PsiMethod method = properties.getMethod();
|
||||
if (parent instanceof PsiCallExpression && PsiPolyExpressionUtil.isMethodCallPolyExpression((PsiExpression)parent, method)) {
|
||||
final PsiType returnType = method.getReturnType();
|
||||
@@ -389,12 +390,17 @@ public class InferenceSession {
|
||||
}
|
||||
|
||||
if (targetType != null && !PsiType.VOID.equals(targetType)) {
|
||||
registerReturnTypeConstraints(PsiUtil.isRawSubstitutor(method, mySiteSubstitutor) ? returnType : mySiteSubstitutor.substitute(returnType), targetType);
|
||||
PsiType actualType = PsiUtil.isRawSubstitutor(method, mySiteSubstitutor) ? returnType : mySiteSubstitutor.substitute(returnType);
|
||||
registerReturnTypeConstraints(actualType, targetType);
|
||||
expectedActualErrorMessage = "Incompatible types. Required " + targetType.getPresentableText() + " but '" + method.getName() + "' was inferred to " + actualType.getPresentableText() + ":";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!repeatInferencePhases()) {
|
||||
if (expectedActualErrorMessage != null && myErrorMessages != null) {
|
||||
myErrorMessages.add(0, expectedActualErrorMessage);
|
||||
}
|
||||
resolveBounds(getInputInferenceVariablesFromTopLevelFunctionalExpressions(args, properties), initialSubstitutor);
|
||||
return;
|
||||
}
|
||||
|
||||
+2
-1
@@ -7,7 +7,8 @@ abstract class Test {
|
||||
abstract <T> T test(Serializable type);
|
||||
|
||||
private void call(){
|
||||
String s = <error descr="no instance(s) of type variable(s) exist so that String[] conforms to String
|
||||
String s = <error descr="Incompatible types. Required String but 'test' was inferred to T:
|
||||
no instance(s) of type variable(s) exist so that String[] conforms to String
|
||||
inference variable T has incompatible bounds:
|
||||
equality constraints: String[]
|
||||
upper bounds: Object, String">test(String[].class);</error>
|
||||
|
||||
+2
-1
@@ -9,7 +9,8 @@ class A {
|
||||
<error descr="Missing return statement">}</error>);
|
||||
|
||||
|
||||
Map<Integer, Integer> map = Stream.iterate(5, <error descr="no instance(s) of type variable(s) T exist so that Stream<T> conforms to Map<Integer, Integer>">t -> t + 5</error>);
|
||||
Map<Integer, Integer> map = Stream.iterate(5, <error descr="Incompatible types. Required Map<Integer, Integer> but 'iterate' was inferred to Stream<T>:
|
||||
no instance(s) of type variable(s) T exist so that Stream<T> conforms to Map<Integer, Integer>">t -> t + 5</error>);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -153,7 +153,7 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
|
||||
boolean found = false;
|
||||
for (String tooltip : tooltips) {
|
||||
if (tooltip.contains("reason: no instance(s) of type variable(s) K, U exist so that Map<K, U> conforms to Function<U, V>")) {
|
||||
if (tooltip.contains("no instance(s) of type variable(s) K, U exist so that Map<K, U> conforms to Function<U, V>")) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user