Permalink
Browse files

Gate coroutines behind directory

Summary:
We want to gate coroutines behind a specific directory in `www` when we ship to `www`. I have chosen to gate it behind `flib/core/hack/lib/experimental` for the time being.

Added this as a `tast_check`, which involved added `at_method_` to the visitor.

Differential Revision: D8555694

fbshipit-source-id: 1016e792d07cd4ba15b14367e699a5cf0f1e6603
  • Loading branch information...
Thomas Jiang authored and hhvm-bot committed Jul 16, 2018
1 parent 98f85fa commit 66d3949198e7e38bec7a4176b4e4af12be2daead
@@ -360,8 +360,10 @@ and gconst = {
cst_is_define: bool;
}
and fun_def = fun_
and def =
| Fun of fun_
| Fun of fun_def
| Class of class_
| Typedef of typedef
| Constant of gconst
@@ -492,6 +492,7 @@ module Typing = struct
| ReassignMutableThis
| MutableExpressionAsMultipleMutableArguments
| InvalidUnsetTargetInRx
| CoroutineOutsideExperimental
(* EXTEND HERE WITH NEW VALUES IF NEEDED *)
[@@ deriving enum, show { with_path = false } ]
let err_code = to_enum
@@ -2719,6 +2719,10 @@ let invalid_ppl_static_call pos reason =
let error_msg = "Cannot call a static method on a <<__PPL>> class "^reason in
add (Typing.err_code Typing.InvalidPPLStaticCall) pos error_msg
let coroutine_outside_experimental pos =
add (Typing.err_code Typing.CoroutineOutsideExperimental) pos
Coroutine_errors.error_message
let return_disposable_mismatch pos1_return_disposable pos1 pos2 =
let m1 = "This is marked <<__ReturnDisposable>>." in
let m2 = "This is not marked <<__ReturnDisposable>>." in
@@ -472,6 +472,7 @@ module type S = sig
val coroutinness_mismatch : bool -> Pos.t -> Pos.t -> unit
val invalid_ppl_call : Pos.t -> string -> unit
val invalid_ppl_static_call : Pos.t -> string -> unit
val coroutine_outside_experimental : Pos.t -> unit
val return_disposable_mismatch : bool -> Pos.t -> Pos.t -> unit
val fun_reactivity_mismatch : Pos.t -> string -> Pos.t -> string -> unit
val frozen_in_incorrect_scope : Pos.t -> unit
@@ -0,0 +1,12 @@
(**
* Copyright (c) 2018, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*)
let handler = object
inherit Tast_visitor.handler_base
end
@@ -0,0 +1,10 @@
(**
* Copyright (c) 2018, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*)
let error_message = ""
@@ -13,6 +13,7 @@ let visitor = Tast_visitor.iter_with [
Tautology_check.handler;
Type_test_hint_check.handler;
Ppl_check.handler;
Coroutine_check.handler;
]
let program = visitor#go
@@ -63,6 +63,8 @@ let save = Typing_env.save SMap.empty
let forward_compat_ge = Typing_env.forward_compat_ge
let error_if_forward_compat_ge = Typing_env.error_if_forward_compat_ge
let get_file = Typing_env.get_file
let fully_expand = Typing_expand.fully_expand
let get_class_ids = Typing_utils.get_class_ids
@@ -64,6 +64,9 @@ val forward_compat_ge : env -> int -> bool
val error_if_forward_compat_ge : env -> int -> (unit -> unit) -> unit
(** Call the func if the forward compatibility level is new enough *)
val get_file : env -> Relative_path.t
(* Return the {!Relative_path.t} of the file the env is from *)
val expand_type : env -> Tast.ty -> env * Tast.ty
(** Expand a type variable ({!Typing_defs.Tvar}) to the type it refers to. *)
@@ -104,10 +104,11 @@ end
class type handler = object
method minimum_forward_compat_level : int
method at_fun_ : Env.t -> Tast.fun_ -> unit
method at_class_ : Env.t -> Tast.class_ -> unit
method at_typedef : Env.t -> Tast.typedef -> unit
method at_gconst : Env.t -> Tast.gconst -> unit
method at_fun_def : Env.t -> Tast.fun_def -> unit
method at_method_ : Env.t -> Tast.method_ -> unit
method at_expr : Env.t -> Tast.expr -> unit
method at_stmt : Env.t -> Tast.stmt -> unit
@@ -126,10 +127,11 @@ end
class virtual handler_base : handler = object
method minimum_forward_compat_level = 0
method at_fun_ _ _ = ()
method at_class_ _ _ = ()
method at_typedef _ _ = ()
method at_gconst _ _ = ()
method at_fun_def _ _ = ()
method at_method_ _ _ = ()
method at_expr _ _ = ()
method at_stmt _ _ = ()
@@ -147,10 +149,6 @@ let iter_with (handlers : handler list) : iter = object
inherit iter as super
method! on_fun_ env x =
List.iter handlers (if_enabled env (fun v -> v#at_fun_ env x));
super#on_fun_ env x;
method! on_class_ env x =
List.iter handlers (if_enabled env (fun v -> v#at_class_ env x));
super#on_class_ env x;
@@ -163,6 +161,14 @@ let iter_with (handlers : handler list) : iter = object
List.iter handlers (if_enabled env (fun v -> v#at_gconst env x));
super#on_gconst env x;
method! on_fun_def env x =
List.iter handlers (if_enabled env (fun v -> v#at_fun_def env x));
super#on_fun_def env x;
method! on_method_ env x =
List.iter handlers (if_enabled env (fun v -> v#at_method_ env x));
super#on_method_ env x;
method! on_expr env x =
List.iter handlers (if_enabled env (fun v -> v#at_expr env x));
super#on_expr env x;
@@ -486,4 +486,5 @@ InvalidTraversableInRx = 4267
ReassignMutableThis = 4268
MutableExpressionAsMultipleMutableArguments = 4269
InvalidUnsetTargetInRx = 4270
CoroutineOutsideExperimental = 4271
|}]

0 comments on commit 66d3949

Please sign in to comment.