Ver Fonte

[typer] move return_partial_type to typecore globals

Simon Krajewski há 1 ano atrás
pai
commit
8546fa75d3

+ 0 - 1
src/compiler/serverCompilationContext.ml

@@ -46,7 +46,6 @@ let reset sctx =
 	Hashtbl.clear sctx.changed_directories;
 	sctx.was_compilation <- false;
 	Parser.reset_state();
-	return_partial_type := false;
 	measure_times := false;
 	Hashtbl.clear DeprecationCheck.warned_positions;
 	close_times();

+ 2 - 2
src/context/display/displayFields.ml

@@ -39,9 +39,9 @@ let collect_static_extensions ctx items e p =
 	let opt_type t =
 		match t with
 		| TLazy f ->
-			return_partial_type := true;
+			ctx.g.return_partial_type <- true;
 			let t = lazy_type f in
-			return_partial_type := false;
+			ctx.g.return_partial_type <- false;
 			t
 		| _ ->
 			t

+ 1 - 0
src/context/typecore.ml

@@ -115,6 +115,7 @@ type typer_globals = {
 	mutable type_hints : (module_def_display * pos * t) list;
 	mutable load_only_cached_modules : bool;
 	functional_interface_lut : (path,tclass_field) lookup;
+	mutable return_partial_type : bool;
 	(* api *)
 	do_macro : typer -> macro_mode -> path -> string -> expr list -> pos -> macro_result;
 	do_load_macro : typer -> bool -> path -> string -> pos -> ((string * bool * t) list * t * tclass * Type.tclass_field);

+ 0 - 2
src/core/globals.ml

@@ -70,8 +70,6 @@ let trace_call_stack ?(n:int = 5) () =
 
 let macro_platform = ref Neko
 
-let return_partial_type = ref false
-
 let is_windows = Sys.os_type = "Win32" || Sys.os_type = "Cygwin"
 
 let max_custom_target_len = 16

+ 0 - 2
src/core/json/genjson.ml

@@ -215,9 +215,7 @@ let rec generate_type ctx t =
 			| Some t -> loop t
 			end
 		| TLazy f ->
-			(* return_partial_type := true; *)
 			let t = lazy_type f in
-			(* return_partial_type := false; *)
 			loop t
 		| TDynamic None -> "TDynamic", Some jnull
 		| TDynamic (Some t) -> "TDynamic",Some (generate_type ctx t)

+ 2 - 2
src/typing/typeloadFields.ml

@@ -857,7 +857,7 @@ module TypeBinding = struct
 		in
 		let r = make_lazy ~force:false ctx t (fun r ->
 			(* type constant init fields (issue #1956) *)
-			if not !return_partial_type || (match fst e with EConst _ -> true | _ -> false) then begin
+			if not ctx.g.return_partial_type || (match fst e with EConst _ -> true | _ -> false) then begin
 				enter_field_typing_pass ctx ("bind_var_expression",fst ctx.curclass.cl_path @ [snd ctx.curclass.cl_path;ctx.curfield.cf_name]);
 				if (Meta.has (Meta.Custom ":debug.typing") (c.cl_meta @ cf.cf_meta)) then ctx.com.print (Printf.sprintf "Typing field %s.%s\n" (s_type_path c.cl_path) cf.cf_name);
 				let e = type_var_field ctx t e fctx.is_static fctx.is_display_field p in
@@ -986,7 +986,7 @@ module TypeBinding = struct
 			end;
 		in
 		let maybe_bind r =
-			if not !return_partial_type then bind r;
+			if not ctx.g.return_partial_type then bind r;
 			t
 		in
 		let r = make_lazy ~force:false ctx t maybe_bind "type_fun" in

+ 1 - 0
src/typing/typerEntry.ml

@@ -25,6 +25,7 @@ let create com macros =
 			complete = false;
 			type_hints = [];
 			load_only_cached_modules = false;
+			return_partial_type = false;
 			functional_interface_lut = new Lookup.pmap_lookup;
 			do_macro = MacroContext.type_macro;
 			do_load_macro = MacroContext.load_macro';