2
0
Simon Krajewski 5 сар өмнө
parent
commit
e0a26d88c4

+ 13 - 13
src/context/safeCom.ml

@@ -25,27 +25,27 @@ type t = {
 	curfield : tclass_field;
 }
 
-let add_exn com exn =
-	Mutex.protect com.exceptions_mutex (fun () -> com.exceptions := exn :: !(com.exceptions))
+let add_exn scom exn =
+	Mutex.protect scom.exceptions_mutex (fun () -> scom.exceptions := exn :: !(scom.exceptions))
 
-let add_warning com w msg p =
-	let options = (Warning.from_meta com.curfield.cf_meta) @ (Warning.from_meta com.curclass.cl_meta) in
+let add_warning scom w msg p =
+	let options = (Warning.from_meta scom.curfield.cf_meta) @ (Warning.from_meta scom.curclass.cl_meta) in
 	match Warning.get_mode w options with
 	| WMEnable ->
-		Mutex.protect com.warnings_mutex (fun () ->
+		Mutex.protect scom.warnings_mutex (fun () ->
 			let warning = {
-				w_module = com.curclass.cl_module;
+				w_module = scom.curclass.cl_module;
 				w_warning = w;
 				w_options = options;
 				w_msg = msg;
 				w_pos = p;
 			} in
-			com.warnings := warning :: !(com.warnings)
+			scom.warnings := warning :: !(scom.warnings)
 		)
 	| WMDisable ->
 		()
 
-let run_expression_filters_safe (com : t) detail_times filters t =
+let run_expression_filters_safe scom detail_times filters t =
 	let run com identifier e =
 		try
 			List.fold_left (fun e (filter_name,f) ->
@@ -61,14 +61,14 @@ let run_expression_filters_safe (com : t) detail_times filters t =
 	match t with
 	| TClassDecl c when FilterContext.is_removable_class c -> ()
 	| TClassDecl c ->
-		let com = {com with curclass = c} in
+		let scom = {scom with curclass = c} in
 		let rec process_field cf =
 			if not (has_class_field_flag cf CfPostProcessed) then begin
-				let com = {com with curfield = cf} in
+				let scom = {scom with curfield = cf} in
 				(match cf.cf_expr with
-				| Some e when not (FilterContext.is_removable_field com.is_macro_context cf) ->
+				| Some e when not (FilterContext.is_removable_field scom.is_macro_context cf) ->
 					let identifier = Printf.sprintf "%s.%s" (s_type_path c.cl_path) cf.cf_name in
-					cf.cf_expr <- Some (run com (Some identifier) e);
+					cf.cf_expr <- Some (run scom (Some identifier) e);
 				| _ -> ());
 			end;
 			List.iter process_field cf.cf_overloads
@@ -82,7 +82,7 @@ let run_expression_filters_safe (com : t) detail_times filters t =
 		| None -> ()
 		| Some e ->
 			let identifier = Printf.sprintf "%s.__init__" (s_type_path c.cl_path) in
-			TClass.set_cl_init c (run com (Some identifier) e))
+			TClass.set_cl_init c (run scom (Some identifier) e))
 	| TEnumDecl _ -> ()
 	| TTypeDecl _ -> ()
 	| TAbstractDecl _ -> ()

+ 5 - 5
src/filters/filters.ml

@@ -437,7 +437,7 @@ let run tctx ectx main before_destruction =
 		not cached
 	) com.types in
 	let new_types_array = Array.of_list new_types in
-	let safe_com = to_safe_com com in
+	let scom = to_safe_com com in
 	(* IMPORTANT:
 	    There may be types in new_types which have already been post-processed, but then had their m_processed flag unset
 		because they received an additional dependency. This could happen in cases such as @:generic methods in #10635.
@@ -459,8 +459,8 @@ let run tctx ectx main before_destruction =
 		"check_local_vars_init",CheckVarInit.check_local_vars_init;
 		"check_abstract_as_value",SafeFilters.check_abstract_as_value;
 	] in
-	run_parallel_safe com safe_com (fun pool ->
-		Parallel.ParallelArray.iter pool (SafeCom.run_expression_filters_safe safe_com detail_times filters) new_types_array
+	run_parallel_safe com scom (fun pool ->
+		Parallel.ParallelArray.iter pool (SafeCom.run_expression_filters_safe scom detail_times filters) new_types_array
 	);
 	let filters = [
 		"Tre",if defined com Define.AnalyzerOptimize then Tre.run else (fun _ e -> e);
@@ -483,8 +483,8 @@ let run tctx ectx main before_destruction =
 		| _ -> (fun scom e -> RenameVars.run scom.curclass.cl_path locals e));
 		"mark_switch_break_loops",SafeFilters.mark_switch_break_loops;
 	] in
-	run_parallel_safe com safe_com (fun pool ->
-		Parallel.ParallelArray.iter pool (SafeCom.run_expression_filters_safe safe_com detail_times filters) new_types_array
+	run_parallel_safe com scom (fun pool ->
+		Parallel.ParallelArray.iter pool (SafeCom.run_expression_filters_safe scom detail_times filters) new_types_array
 	);
 	with_timer detail_times "callbacks" None (fun () ->
 		com.callbacks#run com.error_ext com.callbacks#get_before_save;

+ 2 - 2
tests/display/src/cases/Issue11211.hx

@@ -31,7 +31,7 @@ class Issue11211 extends DisplayTestCase {
 		@:build(Issue11211.SafeAst.build())
 		class Main {
 			static function main() {
-				var errRa{-1-}nge = 0;
+				var errRa{-1-}nge:Null<Int> = 0;
 				{-4-}final pre{-2-}vId = trace("arg");{-5-}
 				if (errRange != null) {
 					final has{-3-}Comma = false;
@@ -41,7 +41,7 @@ class Issue11211 extends DisplayTestCase {
 		#end
 	**/
 	function test() {
-		eq("Int", type(pos(1)));
+		eq("Null<Int>", type(pos(1)));
 		eq("Void", type(pos(2)));
 		eq("Bool", type(pos(3)));
 		arrayEq([