Avoid using decl_class_type wherever possible
[hiphop-php.git] / hphp / hack / src / typing / tast_check / dynamic_method_call_check.ml
blob83a6e4ab7cc2ceb68bb43b8e4edf52d8653fea31
1 (**
2 * Copyright (c) 2018, Facebook, Inc.
3 * All rights reserved.
5 * This source code is licensed under the MIT license found in the
6 * LICENSE file in the "hack" directory of this source tree.
8 *)
10 open Tast
11 open Typing_defs
13 module Env = Tast_env
15 let handler = object
16 inherit Tast_visitor.handler_base
18 method! at_Call env _ expr _ _ _ =
19 match snd expr with
20 (* If rhs's expression is some Id, then we've got a normal function call
21 * $x->foo
22 * That's totally fine, ignore it. *)
23 | Obj_get (_, (_, Id _), _) -> ()
24 (* Otherwise, rhs is some dynamic invocation expression like: $x->$f *)
25 (* if lhs is already dynamic, we let the dynamic invoke happen for now *)
26 | Obj_get (((_, (_, Tdynamic)), _), _, _) -> ()
27 (* if it's not dynamic, then we're in our error case. Grab the offending
28 * expression's position and report it *)
29 | Obj_get (_, ((rhs_pos, _), _), _)
30 when Env.is_strict env ->
31 Errors.dynamic_method_call rhs_pos
32 | _ -> ()
33 end