mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-07 22:09:38 +07:00
new inference: provide diagnostics on failed inference (type compatibility constraints)
This commit is contained in:
@@ -39,7 +39,11 @@ public class TypeCompatibilityConstraint implements ConstraintFormula {
|
||||
@Override
|
||||
public boolean reduce(InferenceSession session, List<ConstraintFormula> constraints) {
|
||||
if (session.isProperType(myT) && session.isProperType(myS)) {
|
||||
return TypeConversionUtil.isAssignable(myT, myS);
|
||||
final boolean assignable = TypeConversionUtil.isAssignable(myT, myS);
|
||||
if (!assignable) {
|
||||
session.registerIncompatibleErrorMessage("Incompatible types: " + myS.getPresentableText() + " is not convertible to " + myS.getPresentableText());
|
||||
}
|
||||
return assignable;
|
||||
}
|
||||
if (myS instanceof PsiPrimitiveType) {
|
||||
final PsiClassType boxedType = ((PsiPrimitiveType)myS).getBoxedType(session.getManager(), session.getScope());
|
||||
|
||||
@@ -68,13 +68,18 @@ public class TypeEqualityConstraint implements ConstraintFormula {
|
||||
}
|
||||
|
||||
if (myT instanceof PsiWildcardType || myS instanceof PsiWildcardType) {
|
||||
session.registerIncompatibleErrorMessage("Incompatible equality constraint: " + myT.getPresentableText() + " and " + myS.getPresentableText());
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
return Comparing.equal(myT, myS);
|
||||
final boolean equal = Comparing.equal(myT, myS);
|
||||
if (!equal) {
|
||||
session.registerIncompatibleErrorMessage("Incompatible equality constraint: " + myT.getPresentableText() + " and " + myS.getPresentableText());
|
||||
}
|
||||
return equal;
|
||||
}
|
||||
InferenceVariable inferenceVariable = session.getInferenceVariable(myS);
|
||||
if (inferenceVariable != null) {
|
||||
|
||||
Reference in New Issue
Block a user