mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
inference: raise unchecked warning if low/equals bounds are not assignable without unchecked conversion (IDEA-150495)
This commit is contained in:
@@ -1085,6 +1085,11 @@ public class InferenceSession {
|
||||
return registerIncompatibleErrorMessage(var, incompatibleBoundsMessage);
|
||||
} else {
|
||||
type = eqBound;
|
||||
|
||||
if (!TypeConversionUtil.isAssignable(eqBound, lowerBound, false)) {
|
||||
setErased();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1110,10 +1115,10 @@ public class InferenceSession {
|
||||
for (PsiType upperType : var.getBounds(InferenceBound.UPPER)) {
|
||||
if (isProperType(upperType) ) {
|
||||
String incompatibleBoundsMessage = null;
|
||||
if (type != lowerBound && !TypeConversionUtil.isAssignable(substitutor.substitute(upperType), type)) {
|
||||
if (type != lowerBound && !TypeConversionUtil.isAssignable(upperType, type)) {
|
||||
incompatibleBoundsMessage = incompatibleBoundsMessage(var, substitutor, InferenceBound.EQ, EQUALITY_CONSTRAINTS_PRESENTATION, InferenceBound.UPPER, UPPER_BOUNDS_PRESENTATION);
|
||||
}
|
||||
else if (type == lowerBound && !TypeConversionUtil.isAssignable(substitutor.substitute(upperType), lowerBound)) {
|
||||
else if (type == lowerBound && !TypeConversionUtil.isAssignable(upperType, lowerBound)) {
|
||||
incompatibleBoundsMessage = incompatibleBoundsMessage(var, substitutor, InferenceBound.LOWER, LOWER_BOUNDS_PRESENTATION, InferenceBound.UPPER, UPPER_BOUNDS_PRESENTATION);
|
||||
}
|
||||
if (incompatibleBoundsMessage != null) {
|
||||
|
||||
@@ -60,10 +60,6 @@ public class ExpressionCompatibilityConstraint extends InputOutputConstraintForm
|
||||
if (((PsiClassType)exprType).resolve() == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (((PsiClassType)exprType).isRaw()) {
|
||||
session.setErased();
|
||||
}
|
||||
}
|
||||
|
||||
if (exprType != null && exprType != PsiType.NULL) {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
class Issue {
|
||||
public void some(String group) {
|
||||
new HashSet<Permission>().stream()
|
||||
.map(permission -> (PrincipalPermission) permission)
|
||||
.filter(permission -> group.equals(permission.getGroup()));
|
||||
}
|
||||
}
|
||||
|
||||
class Permission {
|
||||
}
|
||||
|
||||
class PrincipalPermission<<warning descr="Type parameter 'T' is never used">T</warning>> extends Permission {
|
||||
public String getGroup() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -950,4 +950,8 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testCastingCapturedWildcardToArray() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testCheckUncheckedAssignmentDuringVariablesResaolution() throws Exception {
|
||||
doTest(true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user