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

[TypeUtils.findOverridenMethod] Skip found methods with default access and not same package #3603

Merged
Merged
Changes from 3 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 @@ -414,6 +414,12 @@ public static Optional<JavaType.Method> findOverriddenMethod(@Nullable JavaType.
}
}
}

// Check if access level is default then check if subclass package is the same from parent class
if (isDefaultAccessLevel(method.getFlags())) {
methodResult = methodResult.filter(m -> m.getDeclaringType().getPackageName().equals(dt.getPackageName()));
}

return methodResult.filter(m -> !m.getFlags().contains(Flag.Private) && !m.getFlags().contains(Flag.Static));
}

Expand Down Expand Up @@ -533,6 +539,10 @@ public static JavaType unknownIfNull(@Nullable JavaType t) {
return t;
}

private static boolean isDefaultAccessLevel(final Set<Flag> flags) {
return !flags.contains(Flag.Public) && !flags.contains(Flag.Protected) && !flags.contains(Flag.Private);
}

static boolean deepEquals(@Nullable List<? extends JavaType> ts1, @Nullable List<? extends JavaType> ts2) {

if (ts1 == null || ts2 == null) {
Expand Down