Skip to content

Commit

Permalink
Fix "Redundant superinterface" warning depends on Interface name
Browse files Browse the repository at this point in the history
SuperTypeTest.test016(), SuperTypeTest.test017() failed when
implementation of ReferenceBinding.hashCode() changed.

The message was either
"already defined by IChangeRulerColumn" or
"already defined by IRevisionRulerColumn"
depending on which Interface had the lower hashCode.

relates to
eclipse-jdt#3412
  • Loading branch information
EcljpseB0T committed Dec 9, 2024
1 parent d37105b commit b0a8cc2
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
Expand Down Expand Up @@ -321,12 +322,12 @@ void checkForRedundantSuperinterfaces(ReferenceBinding superclass, ReferenceBind
}

ReferenceBinding[] itsInterfaces = null;
SimpleSet inheritedInterfaces = new SimpleSet(5);
Set<ReferenceBinding> inheritedInterfaces = new LinkedHashSet<>();
ReferenceBinding superType = superclass;
while (superType != null && superType.isValidBinding()) {
if ((itsInterfaces = superType.superInterfaces()) != Binding.NO_SUPERINTERFACES) {
for (ReferenceBinding inheritedInterface : itsInterfaces) {
if (!inheritedInterfaces.includes(inheritedInterface) && inheritedInterface.isValidBinding()) {
if (!inheritedInterfaces.contains(inheritedInterface) && inheritedInterface.isValidBinding()) {
if (interfacesToCheck.includes(inheritedInterface)) {
if (redundantInterfaces == null) {
redundantInterfaces = new SimpleSet(3);
Expand All @@ -350,10 +351,9 @@ void checkForRedundantSuperinterfaces(ReferenceBinding superclass, ReferenceBind
superType = superType.superclass();
}

int nextPosition = inheritedInterfaces.elementSize;
int nextPosition = inheritedInterfaces.size();
if (nextPosition == 0) return;
ReferenceBinding[] interfacesToVisit = new ReferenceBinding[nextPosition];
inheritedInterfaces.asArray(interfacesToVisit);
ReferenceBinding[] interfacesToVisit = inheritedInterfaces.toArray(ReferenceBinding[]::new);
for (int i = 0; i < nextPosition; i++) {
superType = interfacesToVisit[i];
if ((itsInterfaces = superType.superInterfaces()) != Binding.NO_SUPERINTERFACES) {
Expand All @@ -362,7 +362,7 @@ void checkForRedundantSuperinterfaces(ReferenceBinding superclass, ReferenceBind
System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[nextPosition + itsLength + 5], 0, nextPosition);
for (int a = 0; a < itsLength; a++) {
ReferenceBinding inheritedInterface = itsInterfaces[a];
if (!inheritedInterfaces.includes(inheritedInterface) && inheritedInterface.isValidBinding()) {
if (!inheritedInterfaces.contains(inheritedInterface) && inheritedInterface.isValidBinding()) {
if (interfacesToCheck.includes(inheritedInterface)) {
if (redundantInterfaces == null) {
redundantInterfaces = new SimpleSet(3);
Expand Down

0 comments on commit b0a8cc2

Please sign in to comment.