Skip to content

Commit

Permalink
Fix duplicate hover type bug
Browse files Browse the repository at this point in the history
Summary: Whenever the receiver of a method has type ~C, the signature of the method is shown twice. This diff suggests a fix

Reviewed By: mheiber

Differential Revision: D69860562

fbshipit-source-id: ad32581f0dcb17534a49ca8e95b07049d09b3b07
  • Loading branch information
Catherine Gasnier authored and facebook-github-bot committed Feb 21, 2025
1 parent bc72b76 commit 1f138ef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
11 changes: 11 additions & 0 deletions hphp/hack/src/client_and_server/identifySymbolService.ml
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,16 @@ let process_class class_ =
~kind:`Method
| None -> acc

let possibly_remove_unknown_classes classes =
let is_class_name = function
| ClassName _ -> true
| UnknownClass -> false
in
if List.exists classes ~f:is_class_name then
List.filter classes ~f:is_class_name
else
classes

let typed_member_id env receiver_ty mid ~kind =
Tast_env.get_receiver_ids env receiver_ty
|> List.map ~f:(function
Expand All @@ -298,6 +308,7 @@ let typed_member_id env receiver_ty mid ~kind =
| Tast_env.RIerr
| Tast_env.RIany ->
UnknownClass)
|> possibly_remove_unknown_classes
|> List.map ~f:(fun rid -> process_member rid mid ~kind)
|> List.fold ~init:Result_set.empty ~f:Result_set.union

Expand Down
2 changes: 0 additions & 2 deletions hphp/hack/test/hover/method_call_vec.php.exp
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
// Defined in FooParent
public function bar(): void
-------------
function bar(): void
2 changes: 0 additions & 2 deletions hphp/hack/test/hover/method_like_type.php.exp
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
// Defined in C
public function f(): void
-------------
function f(): void

0 comments on commit 1f138ef

Please sign in to comment.