Преглед изворни кода

Do not run deprecation checks on cached types (#12232)

* Do not run deprecation checks on cached types

* [tests] Add test for #12174

* Move deprecation check to Filters.run
Rudy Ges пре 4 месеци
родитељ
комит
8b3761f712

+ 0 - 1
src/compiler/compiler.ml

@@ -347,7 +347,6 @@ let finalize_typing ctx tctx =
 
 
 let filter ctx tctx ectx before_destruction =
 let filter ctx tctx ectx before_destruction =
 	Timer.time ctx.timer_ctx ["filters"] (fun () ->
 	Timer.time ctx.timer_ctx ["filters"] (fun () ->
-		DeprecationCheck.run ctx.com;
 		run_or_diagnose ctx (fun () -> Filters.run tctx ectx ctx.com.main.main_expr before_destruction)
 		run_or_diagnose ctx (fun () -> Filters.run tctx ectx ctx.com.main.main_expr before_destruction)
 	) ()
 	) ()
 
 

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

@@ -99,7 +99,7 @@ let run_on_field dctx cf =
 	| _ ->
 	| _ ->
 		()
 		()
 
 
-let run com =
+let run com types =
 	let dctx = create_context com in
 	let dctx = create_context com in
 	List.iter (fun t -> match t with
 	List.iter (fun t -> match t with
 		| TClassDecl c when not (Meta.has Meta.Deprecated c.cl_meta) ->
 		| TClassDecl c when not (Meta.has Meta.Deprecated c.cl_meta) ->
@@ -110,7 +110,7 @@ let run com =
 			List.iter (run_on_field dctx) c.cl_ordered_fields;
 			List.iter (run_on_field dctx) c.cl_ordered_fields;
 		| _ ->
 		| _ ->
 			()
 			()
-	) com.types
+	) types
 
 
 let check_is com m cl_meta cf_meta name meta p =
 let check_is com m cl_meta cf_meta name meta p =
 	let dctx = {
 	let dctx = {

+ 3 - 2
src/filters/filters.ml

@@ -499,9 +499,10 @@ let run com ectx main before_destruction =
 		It is important that all filters from here up to save_class_state only process fields which do not have the
 		It is important that all filters from here up to save_class_state only process fields which do not have the
 		CfPostProcessed flag set.
 		CfPostProcessed flag set.
 
 
-		This is mostly covered by run_expression_filters already, but any new additions which don't utilize that have to
-		be aware of this.
+		This is mostly covered by run_expression_filters_safe already, but any new additions which don't utilize that have
+		to be aware of this.
 	*)
 	*)
+	DeprecationCheck.run com new_types;
 	NullSafety.run com new_types;
 	NullSafety.run com new_types;
 	let cv_wrapper_impl = CapturedVars.get_wrapper_implementation com in
 	let cv_wrapper_impl = CapturedVars.get_wrapper_implementation com in
 	let rename_locals_config = RenameVars.init scom.SafeCom.platform_config com.types in
 	let rename_locals_config = RenameVars.init scom.SafeCom.platform_config com.types in

+ 17 - 0
tests/server/src/cases/issues/Issue12174.hx

@@ -0,0 +1,17 @@
+package cases.issues;
+
+import haxe.display.Diagnostic;
+
+class Issue12174 extends TestCase {
+	function test(_) {
+		vfs.putContent("Main.hx", getTemplate("issues/Issue12174.hx"));
+		var args = ["-main", "Main"];
+		runHaxe(args);
+		assertSuccess();
+		Assert.equals(1, messages.filter(m -> m.contains("WDeprecated")).length);
+
+		runHaxe(args);
+		assertSuccess();
+		Assert.equals(1, messages.filter(m -> m.contains("WDeprecated")).length);
+	}
+}

+ 6 - 0
tests/server/test/templates/issues/Issue12174.hx

@@ -0,0 +1,6 @@
+@:deprecated
+function deprecated() {}
+
+function main() {
+	deprecated();
+}