diff --git a/framework/src/main/java/org/checkerframework/framework/util/typeinference8/constraint/Expression.java b/framework/src/main/java/org/checkerframework/framework/util/typeinference8/constraint/Expression.java index 69b4fa1d7ff..0ff8fdd1f9c 100644 --- a/framework/src/main/java/org/checkerframework/framework/util/typeinference8/constraint/Expression.java +++ b/framework/src/main/java/org/checkerframework/framework/util/typeinference8/constraint/Expression.java @@ -280,7 +280,11 @@ private ReductionResultPair reduceLambda(Java8InferenceContext context) { AbstractType gi = gs.get(i); constraintSet.add(new Typing(fi, gi, TypeConstraint.Kind.TYPE_EQUALITY)); } - constraintSet.add(new Typing(tPrime, T, TypeConstraint.Kind.SUBTYPE)); + @SuppressWarnings("interning:not.interned") // checking for exact object. + boolean tPrimeNotSameAsT = tPrime != T; + if (tPrimeNotSameAsT) { + constraintSet.add(new Typing(tPrime, T, TypeConstraint.Kind.SUBTYPE)); + } } else { context.addLambdaParms(lambda.getParameters()); } diff --git a/framework/src/main/java/org/checkerframework/framework/util/typeinference8/types/VariableBounds.java b/framework/src/main/java/org/checkerframework/framework/util/typeinference8/types/VariableBounds.java index cc7ad03549a..d2683edf98c 100644 --- a/framework/src/main/java/org/checkerframework/framework/util/typeinference8/types/VariableBounds.java +++ b/framework/src/main/java/org/checkerframework/framework/util/typeinference8/types/VariableBounds.java @@ -558,7 +558,7 @@ public boolean hasWildcardParameterizedLowerOrEqualBound() { public boolean hasLowerBoundDifferentParam() { List parameteredTypes = new ArrayList<>(); for (AbstractType type : bounds.get(BoundKind.LOWER)) { - if (!type.isUseOfVariable() && type.isParameterizedType()) { + if (type.isProper() && type.isParameterizedType()) { parameteredTypes.add(type); } } diff --git a/framework/tests/all-systems/Issue6753.java b/framework/tests/all-systems/Issue6753.java new file mode 100644 index 00000000000..2778c29fec0 --- /dev/null +++ b/framework/tests/all-systems/Issue6753.java @@ -0,0 +1,23 @@ +package typearginfer; + +import java.util.Set; +import java.util.concurrent.Callable; + +public abstract class Issue6753 { + + abstract E call(Callable task); + + abstract Set list(); + + void method(int length) { + Set resources = + call( + () -> { + if (length > 1) { + return list(); + } else { + return list(); + } + }); + } +}