Skip to content

Commit

Permalink
Don’t treat builtin-interface-implementing-methods as unused
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Apr 22, 2024
1 parent 1e22e93 commit f4ebb36
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/file_scanner_analyzer/unused_symbols.rs
Expand Up @@ -594,6 +594,7 @@ fn is_method_referenced_somewhere_else(
classlike_info,
method_name_ptr,
referenced_symbols_and_members,
codebase,
) {
return true;
}
Expand All @@ -619,6 +620,7 @@ fn is_method_referenced_somewhere_else(
classlike_info,
method_name_ptr,
referenced_symbols_and_members,
codebase,
) {
return true;
}
Expand All @@ -632,9 +634,18 @@ fn has_upstream_method_call(
classlike_info: &ClassLikeInfo,
method_name_ptr: &StrId,
referenced_class_members: &FxHashSet<(StrId, StrId)>,
codebase: &CodebaseInfo,
) -> bool {
if let Some(parent_elements) = classlike_info.overridden_method_ids.get(method_name_ptr) {
for parent_element in parent_elements {
if let Some(ClassLikeInfo {
user_defined: false,
..
}) = codebase.classlike_infos.get(parent_element)
{
return true;
}

if referenced_class_members.contains(&(*parent_element, *method_name_ptr)) {
return true;
}
Expand Down
13 changes: 13 additions & 0 deletions tests/unused/UnusedCode/memoizableAbstract/input.hack
@@ -0,0 +1,13 @@
abstract class MemoizableParent implements IMemoizeParam {
public function getInstanceKey(): string {
return 'a';
}
}

final class MemoizableChild extends MemoizableParent {
}

<<__EntryPoint>>
function main(): void {
new MemoizableChild();
}

0 comments on commit f4ebb36

Please sign in to comment.