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 d4d6ae852a2..871f9fe03db 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 @@ -1267,11 +1267,14 @@ protected List> allSuperPairsWithCommonGenericType(TypeBinding if (s == null || s.id == TypeIds.T_JavaLangObject || t == null || t.id == TypeIds.T_JavaLangObject) return Collections.emptyList(); List> result = new ArrayList<>(); - if (TypeBinding.equalsEquals(s.original(), t.original())) { + if (s.isParameterizedType() && t.isParameterizedType() // optimization #1: clients of this method only want to compare type arguments + && TypeBinding.equalsEquals(s.original(), t.original())) { result.add(new Pair<>(s, t)); } + if (TypeBinding.equalsEquals(s, t)) + return result; // optimization #2: nothing interesting above equal types TypeBinding tSuper = t.findSuperTypeOriginatingFrom(s); - if (tSuper != null) { + if (tSuper != null && s.isParameterizedType() && tSuper.isParameterizedType()) { // optimization #1 again result.add(new Pair<>(s, tSuper)); } result.addAll(allSuperPairsWithCommonGenericType(s.superclass(), t));