Procházet zdrojové kódy

[typer] fix -D no-deprecation-warnings for typedefs and enums

Jens Fischer před 6 roky
rodič
revize
d2aba58d5d

+ 4 - 2
src/typing/matcher.ml

@@ -197,8 +197,10 @@ module Pattern = struct
 				v
 		in
 		let con_enum en ef p =
-			DeprecationCheck.check_enum pctx.ctx.com en p;
-			DeprecationCheck.check_ef pctx.ctx.com ef p;
+			if not (Common.defined ctx.com Define.NoDeprecationWarnings) then begin
+				DeprecationCheck.check_enum pctx.ctx.com en p;
+				DeprecationCheck.check_ef pctx.ctx.com ef p;
+			end;
 			ConEnum(en,ef),p
 		in
 		let con_static c cf p = ConStatic(c,cf),p in

+ 10 - 9
src/typing/typeload.ml

@@ -247,15 +247,16 @@ let rec load_instance' ctx (t,p) allow_no_params =
 			| TClassDecl {cl_kind = KGeneric} -> true,false
 			| TClassDecl {cl_kind = KGenericBuild _} -> false,true
 			| TTypeDecl td ->
-				begin try
-					let msg = match Meta.get Meta.Deprecated td.t_meta with
-						| _,[EConst(String s),_],_ -> s
-						| _ -> "This typedef is deprecated in favor of " ^ (s_type (print_context()) td.t_type)
-					in
-					ctx.com.warning msg p
-				with Not_found ->
-					()
-				end;
+				if not (Common.defined ctx.com Define.NoDeprecationWarnings) then
+					begin try
+						let msg = match Meta.get Meta.Deprecated td.t_meta with
+							| _,[EConst(String s),_],_ -> s
+							| _ -> "This typedef is deprecated in favor of " ^ (s_type (print_context()) td.t_type)
+						in
+						ctx.com.warning msg p
+					with Not_found ->
+						()
+					end;
 				false,false
 			| _ -> false,false
 		in

+ 3 - 0
tests/misc/projects/Issue4720/compile2.hxml

@@ -0,0 +1,3 @@
+--main Main
+--interp
+-D no-deprecation-warnings

+ 0 - 0
tests/misc/projects/Issue4720/compile2.hxml.stderr