diff --git a/src/context/abstractCast.ml b/src/context/abstractCast.ml index 83867dd48e2..d3cfb057596 100644 --- a/src/context/abstractCast.ml +++ b/src/context/abstractCast.ml @@ -127,7 +127,7 @@ and cast_or_unify ctx tleft eright p = eright let prepare_array_access_field ctx a pl cf p = - let monos = List.map (fun _ -> spawn_monomorph ctx.e p) cf.cf_params in + let monos = List.map (fun _ -> spawn_monomorph ctx p) cf.cf_params in let map t = apply_params a.a_params pl (apply_params cf.cf_params monos t) in let check_constraints () = List.iter2 (fun m ttp -> match get_constraints ttp with diff --git a/src/context/display/displayFields.ml b/src/context/display/displayFields.ml index 842bf97a48c..582d79cb6e0 100644 --- a/src/context/display/displayFields.ml +++ b/src/context/display/displayFields.ml @@ -49,7 +49,7 @@ let collect_static_extensions ctx items e p = let rec dup t = Type.map dup t in let handle_field c f acc = let f = { f with cf_type = opt_type f.cf_type } in - let monos = List.map (fun _ -> spawn_monomorph ctx.e p) f.cf_params in + let monos = List.map (fun _ -> spawn_monomorph ctx p) f.cf_params in let map = apply_params f.cf_params monos in match follow (map f.cf_type) with | TFun((_,_,TType({t_path=["haxe";"macro"], "ExprOf"}, [t])) :: args, ret) diff --git a/src/context/typecore.ml b/src/context/typecore.ml index c9fce0b9b7b..211169bd449 100644 --- a/src/context/typecore.ml +++ b/src/context/typecore.ml @@ -374,7 +374,7 @@ let unify_min_for_type_source ctx el src = (!unify_min_for_type_source_ref) ctx let spawn_monomorph' ctx p = let mono = Monomorph.create () in - ctx.monomorphs.perfunction <- (mono,p) :: ctx.monomorphs.perfunction; + ctx.e.monomorphs.perfunction <- (mono,p) :: ctx.e.monomorphs.perfunction; mono let spawn_monomorph ctx p = diff --git a/src/typing/calls.ml b/src/typing/calls.ml index 6647a9c8ab0..f5b9a6a7b0f 100644 --- a/src/typing/calls.ml +++ b/src/typing/calls.ml @@ -481,7 +481,7 @@ let array_access ctx e1 e2 mode p = let skip_abstract = fast_eq et at in loop ~skip_abstract at | _, _ -> - let pt = spawn_monomorph ctx.e p in + let pt = spawn_monomorph ctx p in let t = ctx.t.tarray pt in begin try unify_raise et t p diff --git a/src/typing/fields.ml b/src/typing/fields.ml index 61bc25f08ae..f58f452b22b 100644 --- a/src/typing/fields.ml +++ b/src/typing/fields.ml @@ -595,7 +595,7 @@ let type_field cfg ctx e i p mode (with_type : WithType.t) = with Exit -> display_error ctx.com (StringError.string_error i (string_source tthis) (s_type (print_context()) tthis ^ " has no field " ^ i)) pfield end; - AKExpr (mk (TField (e,FDynamic i)) (spawn_monomorph ctx.e p) p) + AKExpr (mk (TField (e,FDynamic i)) (spawn_monomorph ctx p) p) let type_field_default_cfg = type_field TypeFieldConfig.default diff --git a/src/typing/forLoop.ml b/src/typing/forLoop.ml index f15e26ee3de..480a9aefeb2 100644 --- a/src/typing/forLoop.ml +++ b/src/typing/forLoop.ml @@ -88,7 +88,7 @@ module IterationKind = struct (mk (TArray (arr,iexpr)) pt p) let check_iterator ?(resume=false) ?last_resort ctx s e p = - let pt = spawn_monomorph ctx.e p in + let pt = spawn_monomorph ctx p in let t = ctx.t.titerator pt in let dynamic_iterator = ref None in let e1 = try diff --git a/src/typing/generic.ml b/src/typing/generic.ml index 62836ab2906..ba9acb9f354 100644 --- a/src/typing/generic.ml +++ b/src/typing/generic.ml @@ -362,7 +362,7 @@ let build_generic_class ctx c p tl = if gctx.generic_debug then print_endline (Printf.sprintf "[GENERIC] %s" (Printer.s_tclass_field " " cf_new)); t in - let t = spawn_monomorph ctx.e p in + let t = spawn_monomorph ctx p in let r = make_lazy ctx.g t (fun () -> let t0 = f() in unify_raise t0 t p; diff --git a/src/typing/instanceBuilder.ml b/src/typing/instanceBuilder.ml index a2b42b0b94b..c316e5ef499 100644 --- a/src/typing/instanceBuilder.ml +++ b/src/typing/instanceBuilder.ml @@ -39,7 +39,7 @@ let build_macro_type ctx pl p = ) in let old = ctx.e.ret in let t = (match ctx.g.do_macro ctx MMacroType path field args p with - | MError | MMacroInMacro -> spawn_monomorph ctx.e p + | MError | MMacroInMacro -> spawn_monomorph ctx p | MSuccess _ -> ctx.e.ret ) in ctx.e.ret <- old; @@ -58,7 +58,7 @@ let build_macro_build ctx c pl cfl p = let old = ctx.e.ret,ctx.c.get_build_infos in ctx.c.get_build_infos <- (fun() -> Some (TClassDecl c, pl, cfl)); let t = (match ctx.g.do_macro ctx MMacroType path field args p with - | MError | MMacroInMacro -> spawn_monomorph ctx.e p + | MError | MMacroInMacro -> spawn_monomorph ctx p | MSuccess _ -> ctx.e.ret ) in ctx.e.ret <- fst old; @@ -73,7 +73,7 @@ let get_build_info ctx mtype p = | TClassDecl c -> if ctx.pass > PBuildClass then ignore(c.cl_build()); let build f s tl = - let t = spawn_monomorph ctx.e p in + let t = spawn_monomorph ctx p in let r = make_lazy ctx.g t (fun () -> let tf = f tl in unify_raise tf t p; diff --git a/src/typing/macroContext.ml b/src/typing/macroContext.ml index 14e6dd13a53..7efe2499139 100644 --- a/src/typing/macroContext.ml +++ b/src/typing/macroContext.ml @@ -989,7 +989,7 @@ let type_macro ctx mode cpath f (el:Ast.expr list) p = | MMacroType -> "ComplexType",(fun () -> let t = if v = Interp.vnull then - spawn_monomorph ctx.e p + spawn_monomorph ctx p else try let ct = Interp.decode_ctype v in Typeload.load_complex_type ctx false LoadNormal ct; diff --git a/src/typing/matcher/exprToPattern.ml b/src/typing/matcher/exprToPattern.ml index e3e897406d9..f1ad1400a58 100644 --- a/src/typing/matcher/exprToPattern.ml +++ b/src/typing/matcher/exprToPattern.ml @@ -63,7 +63,7 @@ let get_general_module_type ctx mt p = let unify_type_pattern ctx mt t p = let tcl = get_general_module_type ctx mt p in match tcl with - | TAbstract(a,_) -> unify ctx (TAbstract(a,[spawn_monomorph ctx.e p])) t p + | TAbstract(a,_) -> unify ctx (TAbstract(a,[spawn_monomorph ctx p])) t p | _ -> die "" __LOC__ let rec make pctx toplevel t e = diff --git a/src/typing/typeload.ml b/src/typing/typeload.ml index 668bfe7d049..98095247878 100644 --- a/src/typing/typeload.ml +++ b/src/typing/typeload.ml @@ -442,7 +442,7 @@ and load_instance ctx ?(allow_display=false) ptp get_params mode = and load_complex_type' ctx allow_display mode (t,p) = match t with | CTParent t -> load_complex_type ctx allow_display mode t - | CTPath { path = {tpackage = ["$"]; tname = "_hx_mono" }} -> spawn_monomorph ctx.e p + | CTPath { path = {tpackage = ["$"]; tname = "_hx_mono" }} -> spawn_monomorph ctx p | CTPath ptp -> load_instance ~allow_display ctx ptp ParamNormal mode | CTOptional _ -> raise_typing_error "Optional type not allowed here" p | CTNamed _ -> raise_typing_error "Named type not allowed here" p @@ -689,7 +689,7 @@ let t_iterator ctx p = match load_qualified_type_def ctx [] "StdTypes" "Iterator" p with | TTypeDecl t -> add_dependency ctx.m.curmod t.t_module MDepFromTyping; - let pt = spawn_monomorph ctx.e p in + let pt = spawn_monomorph ctx p in apply_typedef t [pt], pt | _ -> die "" __LOC__ @@ -699,7 +699,7 @@ let t_iterator ctx p = *) let load_type_hint ?(opt=false) ctx pcur mode t = let t = match t with - | None -> spawn_monomorph ctx.e pcur + | None -> spawn_monomorph ctx pcur | Some (t,p) -> load_complex_type ctx true mode (t,p) in if opt then ctx.t.tnull t else t diff --git a/src/typing/typeloadFunction.ml b/src/typing/typeloadFunction.ml index 411ec97c585..ab207b394e0 100644 --- a/src/typing/typeloadFunction.ml +++ b/src/typing/typeloadFunction.ml @@ -174,7 +174,7 @@ let add_constructor ctx_c c force_constructor p = cf.cf_kind <- cfsup.cf_kind; cf.cf_params <- cfsup.cf_params; cf.cf_meta <- List.filter (fun (m,_,_) -> m = Meta.CompilerGenerated) cfsup.cf_meta; - let t = spawn_monomorph ctx_c.e p in + let t = spawn_monomorph ctx_c p in let r = make_lazy ctx_c.g t (fun () -> let ctx = TyperManager.clone_for_field ctx_c cf cf.cf_params in ignore (follow cfsup.cf_type); (* make sure it's typed *) diff --git a/src/typing/typer.ml b/src/typing/typer.ml index 5c9bb4b90fa..682ceba6c37 100644 --- a/src/typing/typer.ml +++ b/src/typing/typer.ml @@ -40,7 +40,7 @@ let mono_or_dynamic ctx with_type p = match with_type with | WithType.NoValue -> t_dynamic | Value _ | WithType _ -> - spawn_monomorph ctx.e p + spawn_monomorph ctx p let get_iterator_param t = match follow t with @@ -144,7 +144,7 @@ let maybe_type_against_enum ctx f with_type iscall p = let rec unify_min_raise ctx (el:texpr list) : t = let basic = ctx.com.basic in match el with - | [] -> spawn_monomorph ctx.e null_pos + | [] -> spawn_monomorph ctx null_pos | [e] -> e.etype | _ -> let rec chk_null e = is_null e.etype || is_explicit_null e.etype || @@ -172,7 +172,7 @@ let rec unify_min_raise ctx (el:texpr list) : t = with Unify_error _ -> true, t in - let has_error, t = loop (spawn_monomorph ctx.e null_pos) el in + let has_error, t = loop (spawn_monomorph ctx null_pos) el in if not has_error then t else try @@ -394,7 +394,7 @@ let rec type_ident_raise ctx i p mode with_type = AKExpr (mk (TConst TSuper) t p) | "null" -> let acc = - let tnull () = ctx.t.tnull (spawn_monomorph ctx.e p) in + let tnull () = ctx.t.tnull (spawn_monomorph ctx p) in let t = match with_type with | WithType.WithType(t,_) -> begin match follow t with @@ -1140,11 +1140,11 @@ and type_map_declaration ctx e1 el with_type p = | TInst({cl_path=["haxe";"ds"],"IntMap"},[tv]) -> ctx.t.tint,tv,true | TInst({cl_path=["haxe";"ds"],"StringMap"},[tv]) -> ctx.t.tstring,tv,true | TInst({cl_path=["haxe";"ds"],("ObjectMap" | "EnumValueMap")},[tk;tv]) -> tk,tv,true - | _ -> spawn_monomorph ctx.e p,spawn_monomorph ctx.e p,false + | _ -> spawn_monomorph ctx p,spawn_monomorph ctx p,false in match with_type with | WithType.WithType(t,_) -> get_map_params t - | _ -> (spawn_monomorph ctx.e p,spawn_monomorph ctx.e p,false) + | _ -> (spawn_monomorph ctx p,spawn_monomorph ctx p,false) in let keys = Hashtbl.create 0 in let check_key e_key = @@ -1435,7 +1435,7 @@ and type_array_decl ctx el with_type p = mk (TArrayDecl el) (ctx.t.tarray t) p) and type_array_comprehension ctx e with_type p = - let v = gen_local ctx (spawn_monomorph ctx.e p) p in + let v = gen_local ctx (spawn_monomorph ctx p) p in let ev = mk (TLocal v) v.v_type p in let e_ref = snd (store_typed_expr ctx.com ev p) in let et = ref (EConst(Ident "null"),p) in @@ -1997,7 +1997,7 @@ and type_expr ?(mode=MGet) ctx (e,p) (with_type:WithType.t) = } | ECast (e,None) -> let e = type_expr ctx e WithType.value in - mk (TCast (e,None)) (spawn_monomorph ctx.e p) p + mk (TCast (e,None)) (spawn_monomorph ctx p) p | ECast (e, Some t) -> type_cast ctx e t p | EDisplay (e,dk) -> diff --git a/src/typing/typerBase.ml b/src/typing/typerBase.ml index 1bdb1aa33b8..0fc1ee39603 100644 --- a/src/typing/typerBase.ml +++ b/src/typing/typerBase.ml @@ -211,7 +211,7 @@ let type_module_type ctx t p = | TEnumDecl e -> mk (TTypeExpr (TEnumDecl e)) e.e_type p | TTypeDecl s -> - let t = apply_typedef s (List.map (fun _ -> spawn_monomorph ctx.e p) s.t_params) in + let t = apply_typedef s (List.map (fun _ -> spawn_monomorph ctx p) s.t_params) in DeprecationCheck.check_typedef (create_deprecation_context ctx) s p; (match follow t with | TEnum (e,params) -> diff --git a/src/typing/typerDisplay.ml b/src/typing/typerDisplay.ml index 1a6e57e04ab..64d70a4b1ba 100644 --- a/src/typing/typerDisplay.ml +++ b/src/typing/typerDisplay.ml @@ -178,7 +178,7 @@ let raise_toplevel ctx dk with_type (subject,psubject) = DisplayToplevel.collect_and_raise ctx (match dk with DKPattern _ -> TKPattern psubject | _ -> TKExpr psubject) with_type (CRToplevel expected_type) (subject,psubject) psubject let display_dollar_type ctx p make_type = - let mono = spawn_monomorph ctx.e p in + let mono = spawn_monomorph ctx p in let doc = doc_from_string "Outputs type of argument as a warning and uses argument as value" in let arg = ["expression",false,mono] in begin match ctx.com.display.dms_kind with