Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "Redundant superinterface" warning depends on Interface name #3423

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ public void test017() {
"1. ERROR in X.java (at line 11)\n" +
" public final class X extends Y implements IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension {}\n" +
" ^^^^^^^^^^^^^^^^^^^^\n" +
"Redundant superinterface IVerticalRulerColumn for the type X, already defined by IRevisionRulerColumn\n" +
"Redundant superinterface IVerticalRulerColumn for the type X, already defined by IChangeRulerColumn\n" +
"----------\n" +
"2. ERROR in X.java (at line 11)\n" +
" public final class X extends Y implements IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension {}\n" +
Expand All @@ -593,7 +593,7 @@ public void test017() {
"3. ERROR in X.java (at line 11)\n" +
" public final class X extends Y implements IVerticalRulerColumn, IVerticalRulerInfo, IVerticalRulerInfoExtension {}\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Redundant superinterface IVerticalRulerInfoExtension for the type X, already defined by IRevisionRulerColumn\n" +
"Redundant superinterface IVerticalRulerInfoExtension for the type X, already defined by IChangeRulerColumn\n" +
"----------\n",
JavacTestOptions.SKIP);
}
Expand Down
Loading