mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
new inference: don't add primitive equals bounds
This commit is contained in:
@@ -73,21 +73,23 @@ public class TypeEqualityConstraint implements ConstraintFormula {
|
||||
}
|
||||
|
||||
if (session.isProperType(myT) && session.isProperType(myS)) {
|
||||
if (myT == null || myT == PsiType.NULL) return myS == null || myS == PsiType.NULL || myS.equalsToText(CommonClassNames.JAVA_LANG_OBJECT);
|
||||
if (myS == null || myS == PsiType.NULL) return true;
|
||||
final boolean equal = Comparing.equal(myT, myS);
|
||||
if (!equal) {
|
||||
session.registerIncompatibleErrorMessage("Incompatible equality constraint: " + myT.getPresentableText() + " and " + myS.getPresentableText());
|
||||
}
|
||||
return equal;
|
||||
}
|
||||
|
||||
if (myT == null || myT == PsiType.NULL) return false;
|
||||
if (myS == null || myS == PsiType.NULL) return true; //todo raw type in StrictSubtypingConstraint.myS
|
||||
|
||||
InferenceVariable inferenceVariable = session.getInferenceVariable(myS);
|
||||
if (inferenceVariable != null) {
|
||||
if (inferenceVariable != null && !(myT instanceof PsiPrimitiveType)) {
|
||||
inferenceVariable.addBound(myT, InferenceBound.EQ);
|
||||
return true;
|
||||
}
|
||||
inferenceVariable = session.getInferenceVariable(myT);
|
||||
if (inferenceVariable != null) {
|
||||
if (inferenceVariable != null && !(myS instanceof PsiPrimitiveType)) {
|
||||
inferenceVariable.addBound(myS, InferenceBound.EQ);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,6 @@ class ReturnTypeCompatibility {
|
||||
call((String i)->{ return i;});
|
||||
call(i->{ return i;});
|
||||
call(i->"");
|
||||
call(<error descr="no instance(s) of type variable(s) exist so that Integer conforms to int">(int i)->{ return i;}</error>);
|
||||
call(<error descr="no instance(s) of type variable(s) P exist so that P conforms to int">(int i)->{ return i;}</error>);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
class IDEA100385 {
|
||||
void foo(N<Double> n){
|
||||
n.forEach(<error descr="Incompatible parameter types in lambda expression: expected Double but found double">(double e)</error> -> { });
|
||||
n.forEach(<error descr="Cannot infer functional interface type">(double e) -> { }</error>);
|
||||
}
|
||||
static interface N<E> {
|
||||
void forEach(Consumer<? extends E> consumer);
|
||||
|
||||
Reference in New Issue
Block a user