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

Correct cache key of overridden method lookup #10380

Merged
merged 3 commits into from
Jan 17, 2024
Merged
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 @@ -153,16 +153,16 @@ public final void populateTypeHierarchy(C element, List<C> hierarchy) {
* @return the overridden methods
*/
public final Collection<M> findOverriddenMethods(C classNode, M methodElement) {
Object classKey = getClassCacheKey(classNode);
MethodCacheKey cacheKey = new MethodCacheKey(
classKey,
Object classCacheKey = getClassCacheKey(classNode);
MethodCacheKey methodCacheKey = new MethodCacheKey(
classCacheKey,
getMethodCacheKey(methodElement)
);
Collection<M> overriddenMethods = overridesCache.get(cacheKey);
Collection<M> overriddenMethods = overridesCache.get(methodCacheKey);
if (overriddenMethods != null) {
return overriddenMethods;
}
if (processedClasses.contains(classKey)) {
if (processedClasses.contains(classCacheKey)) {
return List.of();
}
List<MethodElement<M>> allElements = getAllElements(classNode);
Expand All @@ -172,14 +172,14 @@ public final Collection<M> findOverriddenMethods(C classNode, M methodElement) {
}
overridesCache.put(
new MethodCacheKey(
classKey,
classCacheKey,
getMethodCacheKey(method.methodElement)
),
method.overridden
);
}
processedClasses.add(classNode);
return overridesCache.getOrDefault(cacheKey, List.of());
processedClasses.add(classCacheKey);
return overridesCache.getOrDefault(methodCacheKey, List.of());
}

private List<MethodElement<M>> getAllElements(C classNode) {
Expand Down