diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java index 4952f0a93fe..761fed52e16 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java @@ -975,7 +975,7 @@ private ConstraintTypeFormula[] typeArgumentEqualityConstraints(TypeBinding s, T for (int i = 0; i < sis.length; i++) { TypeBinding si = sis[i]; TypeBinding ti = tis[i]; - if (si.isWildcard() || ti.isWildcard() || TypeBinding.equalsEquals(si, ti)) + if (isOrContainsWildcard(si) || isOrContainsWildcard(ti) || TypeBinding.equalsEquals(si, ti)) continue; result.add(ConstraintTypeFormula.create(si, ti, ReductionResult.SAME, isSoft)); } @@ -984,6 +984,25 @@ private ConstraintTypeFormula[] typeArgumentEqualityConstraints(TypeBinding s, T return null; } + boolean isOrContainsWildcard(TypeBinding t) { + if (t.isWildcard()) return true; + class FindWildcard extends TypeBindingVisitor { + boolean found; + + @Override + public boolean visit(ParameterizedTypeBinding parameterizedTypeBinding) { + if ((parameterizedTypeBinding.tagBits & TagBits.HasDirectWildcard) != 0) { + this.found = true; + return false; + } + return true; + } + } + FindWildcard visitor = new FindWildcard(); + TypeBindingVisitor.visit(visitor, t); + return visitor.found; + } + /** * Try to reduce the one given constraint. * If a constraint produces further constraints reduce those recursively. diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java index 33a776c7be1..035927ceb45 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_8.java @@ -10864,4 +10864,31 @@ public class TestClass implements TestClass.Missing1 { } + + public interface ObservableEventListener { } + + public interface WritableProperty extends EventSource> { + static

> P getReadOnly(P property) { + return null; + } + } + + public static class Property implements EventSource>, WritableProperty { } + + public static abstract class Bug2413> { + public void foo(P property) { + P readOnly = WritableProperty.getReadOnly(property); + } + } + } + """}); + } }