Browse Source

don't emit a warning about "is" if it already has @:deprecated (#2976)

Aleksandr Kuzmenko 5 years ago
parent
commit
256efbd9cc

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

@@ -123,6 +123,6 @@ let run_on_field ?(force=false) com cf = if_enabled ~force com (fun() -> run_on_
 
 
 let run ?(force=false) com = if_enabled ~force com (fun() -> run com)
 let run ?(force=false) com = if_enabled ~force com (fun() -> run com)
 
 
-let check_is com name p =
-	if name = "is" then
+let check_is com name meta p =
+	if name = "is" && not (Meta.has Meta.Deprecated meta) then
 		warn_deprecation com "Using \"is\" as an identifier is deprecated" p
 		warn_deprecation com "Using \"is\" as an identifier is deprecated" p

+ 1 - 2
src/typing/typeloadFields.ml

@@ -546,8 +546,7 @@ let create_class_context ctx c context_init p =
 	ctx,cctx
 	ctx,cctx
 
 
 let create_field_context (ctx,cctx) c cff =
 let create_field_context (ctx,cctx) c cff =
-	if c.cl_path <> ([],"Std") then
-		DeprecationCheck.check_is ctx.com (fst cff.cff_name) (snd cff.cff_name);
+	DeprecationCheck.check_is ctx.com (fst cff.cff_name) cff.cff_meta (snd cff.cff_name);
 	let ctx = {
 	let ctx = {
 		ctx with
 		ctx with
 		pass = PBuildClass; (* will be set later to PTypeExpr *)
 		pass = PBuildClass; (* will be set later to PTypeExpr *)

+ 10 - 10
src/typing/typeloadModule.ml

@@ -194,8 +194,8 @@ let module_pass_1 ctx m tdecls loadp =
 	let com = ctx.com in
 	let com = ctx.com in
 	let decls = ref [] in
 	let decls = ref [] in
 	let statics = ref [] in
 	let statics = ref [] in
-	let check_name name p =
-		DeprecationCheck.check_is com name p;
+	let check_name name meta p =
+		DeprecationCheck.check_is com name meta p;
 		let error prev_pos =
 		let error prev_pos =
 			display_error ctx ("Name " ^ name ^ " is already defined in this module") p;
 			display_error ctx ("Name " ^ name ^ " is already defined in this module") p;
 			error (compl_msg "Previous declaration here") prev_pos;
 			error (compl_msg "Previous declaration here") prev_pos;
@@ -207,8 +207,8 @@ let module_pass_1 ctx m tdecls loadp =
 			if fst d.d_name = name then error (snd d.d_name)
 			if fst d.d_name = name then error (snd d.d_name)
 		) !statics
 		) !statics
 	in
 	in
-	let make_path name priv p =
-		check_name name p;
+	let make_path name priv meta p =
+		check_name name meta p;
 		if priv then (fst m.m_path @ ["_" ^ snd m.m_path], name) else (fst m.m_path, name)
 		if priv then (fst m.m_path @ ["_" ^ snd m.m_path], name) else (fst m.m_path, name)
 	in
 	in
 	let has_declaration = ref false in
 	let has_declaration = ref false in
@@ -223,7 +223,7 @@ let module_pass_1 ctx m tdecls loadp =
 			if !has_declaration then error "import and using may not appear after a declaration" p;
 			if !has_declaration then error "import and using may not appear after a declaration" p;
 			acc
 			acc
 		| EStatic d ->
 		| EStatic d ->
-			check_name (fst d.d_name) (snd d.d_name);
+			check_name (fst d.d_name) d.d_meta (snd d.d_name);
 			has_declaration := true;
 			has_declaration := true;
 			statics := (d,p) :: !statics;
 			statics := (d,p) :: !statics;
 			acc;
 			acc;
@@ -231,7 +231,7 @@ let module_pass_1 ctx m tdecls loadp =
 			let name = fst d.d_name in
 			let name = fst d.d_name in
 			has_declaration := true;
 			has_declaration := true;
 			let priv = List.mem HPrivate d.d_flags in
 			let priv = List.mem HPrivate d.d_flags in
-			let path = make_path name priv (snd d.d_name) in
+			let path = make_path name priv d.d_meta (snd d.d_name) in
 			let c = mk_class m path p (pos d.d_name) in
 			let c = mk_class m path p (pos d.d_name) in
 			(* we shouldn't load any other type until we propertly set cl_build *)
 			(* we shouldn't load any other type until we propertly set cl_build *)
 			c.cl_build <- (fun() -> error (s_type_path c.cl_path ^ " is not ready to be accessed, separate your type declarations in several files") p);
 			c.cl_build <- (fun() -> error (s_type_path c.cl_path ^ " is not ready to be accessed, separate your type declarations in several files") p);
@@ -252,7 +252,7 @@ let module_pass_1 ctx m tdecls loadp =
 			let name = fst d.d_name in
 			let name = fst d.d_name in
 			has_declaration := true;
 			has_declaration := true;
 			let priv = List.mem EPrivate d.d_flags in
 			let priv = List.mem EPrivate d.d_flags in
-			let path = make_path name priv p in
+			let path = make_path name priv d.d_meta p in
 			if Meta.has (Meta.Custom ":fakeEnum") d.d_meta then error "@:fakeEnum enums is no longer supported in Haxe 4, use extern enum abstract instead" p;
 			if Meta.has (Meta.Custom ":fakeEnum") d.d_meta then error "@:fakeEnum enums is no longer supported in Haxe 4, use extern enum abstract instead" p;
 			let e = {
 			let e = {
 				e_path = path;
 				e_path = path;
@@ -278,7 +278,7 @@ let module_pass_1 ctx m tdecls loadp =
 			if has_meta Meta.Using d.d_meta then error "@:using on typedef is not allowed" p;
 			if has_meta Meta.Using d.d_meta then error "@:using on typedef is not allowed" p;
 			has_declaration := true;
 			has_declaration := true;
 			let priv = List.mem EPrivate d.d_flags in
 			let priv = List.mem EPrivate d.d_flags in
-			let path = make_path name priv p in
+			let path = make_path name priv d.d_meta p in
 			let t = {
 			let t = {
 				t_path = path;
 				t_path = path;
 				t_module = m;
 				t_module = m;
@@ -303,7 +303,7 @@ let module_pass_1 ctx m tdecls loadp =
 		 	let name = fst d.d_name in
 		 	let name = fst d.d_name in
 			check_type_name name d.d_meta;
 			check_type_name name d.d_meta;
 			let priv = List.mem AbPrivate d.d_flags in
 			let priv = List.mem AbPrivate d.d_flags in
-			let path = make_path name priv p in
+			let path = make_path name priv d.d_meta p in
 			let a = {
 			let a = {
 				a_path = path;
 				a_path = path;
 				a_private = priv;
 				a_private = priv;
@@ -442,7 +442,7 @@ let load_enum_field ctx e et is_flat index c =
 		ef_params = params;
 		ef_params = params;
 		ef_meta = c.ec_meta;
 		ef_meta = c.ec_meta;
 	} in
 	} in
-	DeprecationCheck.check_is ctx.com f.ef_name f.ef_name_pos;
+	DeprecationCheck.check_is ctx.com f.ef_name f.ef_meta f.ef_name_pos;
 	let cf = {
 	let cf = {
 		(mk_field f.ef_name f.ef_type p f.ef_name_pos) with
 		(mk_field f.ef_name f.ef_type p f.ef_name_pos) with
 		cf_kind = (match follow f.ef_type with
 		cf_kind = (match follow f.ef_type with

+ 1 - 1
src/typing/typer.ml

@@ -1447,7 +1447,7 @@ and type_vars ctx vl p =
 	let vl = List.map (fun ev ->
 	let vl = List.map (fun ev ->
 		let n = fst ev.ev_name
 		let n = fst ev.ev_name
 		and pv = snd ev.ev_name in
 		and pv = snd ev.ev_name in
-		DeprecationCheck.check_is ctx.com n pv;
+		DeprecationCheck.check_is ctx.com n ev.ev_meta pv;
 		try
 		try
 			let t = Typeload.load_type_hint ctx p ev.ev_type in
 			let t = Typeload.load_type_hint ctx p ev.ev_type in
 			let e = (match ev.ev_expr with
 			let e = (match ev.ev_expr with