Merge Typing_logic.Coerce and Typing_logic.IsSubtype
[hiphop-php.git] / hphp / hack / src / client / clientTastHoles.ml
blobb8c02bf9607600234d629fdba13e7d1b1f9882d4
1 (*
2 * Copyright (c) Facebook, Inc. and its affiliates.
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the "hack" directory of this source tree.
7 *)
8 open Hh_prelude
10 (* Convert result type to tuple since it's not available to
11 Nuclide_rpc_message_printer *)
12 let tast_holes_result_to_tuple
13 TastHolesService.
15 pos;
16 actual_ty_string;
17 expected_ty_string;
18 actual_ty_json;
19 expected_ty_json;
20 } =
21 (actual_ty_string, actual_ty_json, expected_ty_string, expected_ty_json, pos)
23 let print_json result =
24 Nuclide_rpc_message_printer.(
25 print_json
26 @@ tast_holes_response_to_json
27 @@ List.map ~f:tast_holes_result_to_tuple result)
29 let print_string result =
30 let print_elem
31 TastHolesService.{ pos; actual_ty_string; expected_ty_string; _ } =
32 print_endline
33 @@ Format.sprintf
34 {|%s actual type: %s, expected type: %s|}
35 Pos.(string_no_file pos)
36 actual_ty_string
37 expected_ty_string
39 match result with
40 | [] -> print_endline "No TAST Holes"
41 | _ -> List.iter ~f:print_elem result
43 let go result output_json =
44 if output_json then
45 print_json result
46 else
47 print_string result