瀏覽代碼

added deprecation warning to Std.is (#2976)

Aleksandr Kuzmenko 5 年之前
父節點
當前提交
8ef3be1ae8

+ 1 - 0
std/Std.hx

@@ -34,6 +34,7 @@ extern class Std {
 
 
 		If `t` is a class or interface with `@:generic` meta, the result is `false`.
 		If `t` is a class or interface with `@:generic` meta, the result is `false`.
 	**/
 	**/
+	@:deprecated('Std.is is deprecated. Use Std.isOfType instead.')
 	static function is(v:Dynamic, t:Dynamic):Bool;
 	static function is(v:Dynamic, t:Dynamic):Bool;
 
 
 	/**
 	/**

+ 1 - 0
std/cpp/_std/Std.hx

@@ -21,6 +21,7 @@
  */
  */
 @:headerClassCode("\t\tstatic inline String string(String &s) { return s; }")
 @:headerClassCode("\t\tstatic inline String string(String &s) { return s; }")
 @:coreApi class Std {
 @:coreApi class Std {
+	@:deprecated('Std.is is deprecated. Use Std.isOfType instead.')
 	@:keep public static inline function is(v:Dynamic, t:Dynamic):Bool {
 	@:keep public static inline function is(v:Dynamic, t:Dynamic):Bool {
 		return isOfType(v, t);
 		return isOfType(v, t);
 	}
 	}

+ 1 - 1
std/cpp/_std/haxe/Exception.hx

@@ -16,7 +16,7 @@ class Exception {
 	@:noCompletion var __previousException:Null<Exception>;
 	@:noCompletion var __previousException:Null<Exception>;
 
 
 	static function caught(value:Any):Exception {
 	static function caught(value:Any):Exception {
-		if(Std.is(value, Exception)) {
+		if(Std.isOfType(value, Exception)) {
 			return value;
 			return value;
 		} else {
 		} else {
 			return new ValueException(value, null, value);
 			return new ValueException(value, null, value);

+ 1 - 0
std/cs/_std/Std.hx

@@ -24,6 +24,7 @@ import cs.Boot;
 import cs.Lib;
 import cs.Lib;
 
 
 @:coreApi @:nativeGen class Std {
 @:coreApi @:nativeGen class Std {
+	@:deprecated('Std.is is deprecated. Use Std.isOfType instead.')
 	public static inline function is(v:Dynamic, t:Dynamic):Bool {
 	public static inline function is(v:Dynamic, t:Dynamic):Bool {
 		return isOfType(v, t);
 		return isOfType(v, t);
 	}
 	}

+ 1 - 1
std/cs/_std/haxe/Exception.hx

@@ -18,7 +18,7 @@ class Exception extends NativeException {
 	@:noCompletion var __previousException:Null<Exception>;
 	@:noCompletion var __previousException:Null<Exception>;
 
 
 	static public function caught(value:Any):Exception {
 	static public function caught(value:Any):Exception {
-		if(Std.is(value, Exception)) {
+		if(Std.isOfType(value, Exception)) {
 			return value;
 			return value;
 		} else if(Std.isOfType(value, CsException)) {
 		} else if(Std.isOfType(value, CsException)) {
 			return new Exception((value:CsException).Message, null, value);
 			return new Exception((value:CsException).Message, null, value);

+ 1 - 1
std/eval/_std/haxe/Exception.hx

@@ -15,7 +15,7 @@ class Exception {
 	@:noCompletion var __previousException:Null<Exception>;
 	@:noCompletion var __previousException:Null<Exception>;
 
 
 	static function caught(value:Any):Exception {
 	static function caught(value:Any):Exception {
-		if(Std.is(value, Exception)) {
+		if(Std.isOfType(value, Exception)) {
 			return value;
 			return value;
 		} else {
 		} else {
 			return new ValueException(value, null, value);
 			return new ValueException(value, null, value);

+ 1 - 0
std/flash/_std/Std.hx

@@ -23,6 +23,7 @@
 import flash.Boot;
 import flash.Boot;
 
 
 @:coreApi class Std {
 @:coreApi class Std {
+	@:deprecated('Std.is is deprecated. Use Std.isOfType instead.')
 	public static inline function is(v:Dynamic, t:Dynamic):Bool {
 	public static inline function is(v:Dynamic, t:Dynamic):Bool {
 		return isOfType(v, t);
 		return isOfType(v, t);
 	}
 	}

+ 1 - 1
std/flash/_std/haxe/Exception.hx

@@ -16,7 +16,7 @@ class Exception extends NativeException {
 	@:noCompletion var __previousException:Null<Exception>;
 	@:noCompletion var __previousException:Null<Exception>;
 
 
 	static function caught(value:Any):Exception {
 	static function caught(value:Any):Exception {
-		if(Std.is(value, Exception)) {
+		if(Std.isOfType(value, Exception)) {
 			return value;
 			return value;
 		} else if(Std.isOfType(value, Error)) {
 		} else if(Std.isOfType(value, Error)) {
 			return new Exception((value:Error).message, null, value);
 			return new Exception((value:Error).message, null, value);

+ 1 - 0
std/hl/_std/Std.hx

@@ -49,6 +49,7 @@ class Std {
 		return x <= 0 ? 0 : (rnd_int(rnd) & 0x3FFFFFFF) % x;
 		return x <= 0 ? 0 : (rnd_int(rnd) & 0x3FFFFFFF) % x;
 	}
 	}
 
 
+	@:deprecated('Std.is is deprecated. Use Std.isOfType instead.')
 	public static inline function is(v:Dynamic, t:Dynamic):Bool {
 	public static inline function is(v:Dynamic, t:Dynamic):Bool {
 		return isOfType(v, t);
 		return isOfType(v, t);
 	}
 	}

+ 1 - 1
std/hl/_std/haxe/Exception.hx

@@ -15,7 +15,7 @@ class Exception {
 	@:noCompletion var __previousException:Null<Exception>;
 	@:noCompletion var __previousException:Null<Exception>;
 
 
 	static function caught(value:Any):Exception {
 	static function caught(value:Any):Exception {
-		if(Std.is(value, Exception)) {
+		if(Std.isOfType(value, Exception)) {
 			return value;
 			return value;
 		} else {
 		} else {
 			return new ValueException(value, null, value);
 			return new ValueException(value, null, value);

+ 1 - 0
std/java/_std/Std.hx

@@ -24,6 +24,7 @@ import java.Boot;
 import java.Lib;
 import java.Lib;
 
 
 @:coreApi @:nativeGen class Std {
 @:coreApi @:nativeGen class Std {
+	@:deprecated('Std.is is deprecated. Use Std.isOfType instead.')
 	public static inline function is(v:Dynamic, t:Dynamic):Bool {
 	public static inline function is(v:Dynamic, t:Dynamic):Bool {
 		return isOfType(v, t);
 		return isOfType(v, t);
 	}
 	}

+ 1 - 1
std/java/_std/haxe/Exception.hx

@@ -19,7 +19,7 @@ class Exception extends NativeException {
 	@:noCompletion var __previousException:Null<Exception>;
 	@:noCompletion var __previousException:Null<Exception>;
 
 
 	static function caught(value:Any):Exception {
 	static function caught(value:Any):Exception {
-		if(Std.is(value, Exception)) {
+		if(Std.isOfType(value, Exception)) {
 			return value;
 			return value;
 		} else if(Std.isOfType(value, Throwable)) {
 		} else if(Std.isOfType(value, Throwable)) {
 			return new Exception((value:Throwable).getMessage(), null, value);
 			return new Exception((value:Throwable).getMessage(), null, value);

+ 1 - 0
std/js/_std/Std.hx

@@ -25,6 +25,7 @@ import js.Syntax;
 
 
 @:keepInit
 @:keepInit
 @:coreApi class Std {
 @:coreApi class Std {
+	@:deprecated('Std.is is deprecated. Use Std.isOfType instead.')
 	public static inline function is(v:Dynamic, t:Dynamic):Bool {
 	public static inline function is(v:Dynamic, t:Dynamic):Bool {
 		return isOfType(v, t);
 		return isOfType(v, t);
 	}
 	}

+ 2 - 2
std/jvm/_std/Reflect.hx

@@ -123,8 +123,8 @@ class Reflect {
 		if (c1 != (f2 : java.lang.Object).getClass()) {
 		if (c1 != (f2 : java.lang.Object).getClass()) {
 			return false;
 			return false;
 		}
 		}
-		if (Std.is(f1, jvm.Function)) {
-			if (!Std.is(f2, jvm.Function)) {
+		if (Std.isOfType(f1, jvm.Function)) {
+			if (!Std.isOfType(f2, jvm.Function)) {
 				return false;
 				return false;
 			}
 			}
 			return (f1 : jvm.Function).equals(f2);
 			return (f1 : jvm.Function).equals(f2);

+ 1 - 0
std/jvm/_std/Std.hx

@@ -24,6 +24,7 @@ import jvm.Jvm;
 
 
 @:coreApi
 @:coreApi
 class Std {
 class Std {
+	@:deprecated('Std.is is deprecated. Use Std.isOfType instead.')
 	public static inline function is(v:Dynamic, t:Dynamic):Bool {
 	public static inline function is(v:Dynamic, t:Dynamic):Bool {
 		return isOfType(v, t);
 		return isOfType(v, t);
 	}
 	}

+ 1 - 0
std/lua/_std/Std.hx

@@ -25,6 +25,7 @@ import lua.NativeStringTools;
 
 
 @:keepInit
 @:keepInit
 @:coreApi class Std {
 @:coreApi class Std {
+	@:deprecated('Std.is is deprecated. Use Std.isOfType instead.')
 	public static inline function is(v:Dynamic, t:Dynamic):Bool {
 	public static inline function is(v:Dynamic, t:Dynamic):Bool {
 		return isOfType(v, t);
 		return isOfType(v, t);
 	}
 	}

+ 1 - 1
std/lua/_std/haxe/Exception.hx

@@ -15,7 +15,7 @@ class Exception {
 	@:noCompletion var __previousException:Null<Exception>;
 	@:noCompletion var __previousException:Null<Exception>;
 
 
 	static function caught(value:Any):Exception {
 	static function caught(value:Any):Exception {
-		if(Std.is(value, Exception)) {
+		if(Std.isOfType(value, Exception)) {
 			return value;
 			return value;
 		} else {
 		} else {
 			return new ValueException(value, null, value);
 			return new ValueException(value, null, value);

+ 1 - 0
std/neko/_std/Std.hx

@@ -21,6 +21,7 @@
  */
  */
 @:coreApi class Std {
 @:coreApi class Std {
 	@:ifFeature("typed_cast")
 	@:ifFeature("typed_cast")
+	@:deprecated('Std.is is deprecated. Use Std.isOfType instead.')
 	public static inline function is(v:Dynamic, t:Dynamic):Bool {
 	public static inline function is(v:Dynamic, t:Dynamic):Bool {
 		return isOfType(v, t);
 		return isOfType(v, t);
 	}
 	}

+ 1 - 1
std/neko/_std/haxe/Exception.hx

@@ -15,7 +15,7 @@ class Exception {
 	@:noCompletion var __previousException:Null<Exception>;
 	@:noCompletion var __previousException:Null<Exception>;
 
 
 	static function caught(value:Any):Exception {
 	static function caught(value:Any):Exception {
-		if(Std.is(value, Exception)) {
+		if(Std.isOfType(value, Exception)) {
 			return value;
 			return value;
 		} else {
 		} else {
 			return new ValueException(value, null, value);
 			return new ValueException(value, null, value);

+ 1 - 0
std/php/_std/Std.hx

@@ -25,6 +25,7 @@ import php.Const;
 import php.Syntax;
 import php.Syntax;
 
 
 @:coreApi class Std {
 @:coreApi class Std {
+	@:deprecated('Std.is is deprecated. Use Std.isOfType instead.')
 	public static inline function is(v:Dynamic, t:Dynamic):Bool {
 	public static inline function is(v:Dynamic, t:Dynamic):Bool {
 		return isOfType(v, t);
 		return isOfType(v, t);
 	}
 	}

+ 1 - 1
std/php/_std/haxe/Exception.hx

@@ -17,7 +17,7 @@ class Exception extends NativeException {
 	@:noCompletion var __previousException:Null<Exception>;
 	@:noCompletion var __previousException:Null<Exception>;
 
 
 	static function caught(value:Any):Exception {
 	static function caught(value:Any):Exception {
-		if(Std.is(value, Exception)) {
+		if(Std.isOfType(value, Exception)) {
 			return value;
 			return value;
 		} else if(Std.isOfType(value, Throwable)) {
 		} else if(Std.isOfType(value, Throwable)) {
 			return new Exception((value:Throwable).getMessage(), null, value);
 			return new Exception((value:Throwable).getMessage(), null, value);

+ 1 - 0
std/python/_std/Std.hx

@@ -50,6 +50,7 @@ import python.Syntax;
 	}
 	}
 
 
 	@:ifFeature("typed_cast")
 	@:ifFeature("typed_cast")
+	@:deprecated('Std.is is deprecated. Use Std.isOfType instead.')
 	public static inline function is(v:Dynamic, t:Dynamic):Bool {
 	public static inline function is(v:Dynamic, t:Dynamic):Bool {
 		return isOfType(v, t);
 		return isOfType(v, t);
 	}
 	}

+ 1 - 1
std/python/_std/haxe/Exception.hx

@@ -21,7 +21,7 @@ class Exception extends PyException {
 	@:noCompletion var __previousException:Null<Exception>;
 	@:noCompletion var __previousException:Null<Exception>;
 
 
 	static function caught(value:Any):Exception {
 	static function caught(value:Any):Exception {
-		if(Std.is(value, Exception)) {
+		if(Std.isOfType(value, Exception)) {
 			return value;
 			return value;
 		} else if(Std.isOfType(value, BaseException)) {
 		} else if(Std.isOfType(value, BaseException)) {
 			return new Exception(UBuiltins.str(value), null, value);
 			return new Exception(UBuiltins.str(value), null, value);

+ 4 - 4
tests/unit/src/unit/issues/Issue2857.hx.disabled

@@ -5,10 +5,10 @@ class Issue2857 extends unit.Test {
 	function testElement() {
 	function testElement() {
 		if (js.Browser.supported) {
 		if (js.Browser.supported) {
 			var vid = js.Browser.document.createVideoElement();
 			var vid = js.Browser.document.createVideoElement();
-			t(Std.is(vid, js.html.VideoElement));
-			t(Std.is(vid, js.html.Element));
-			f(Std.is(vid, haxe.Http));
-			f(Std.is(vid, js.html.ArrayBuffer));
+			t(Std.isOfType(vid, js.html.VideoElement));
+			t(Std.isOfType(vid, js.html.Element));
+			f(Std.isOfType(vid, haxe.Http));
+			f(Std.isOfType(vid, js.html.ArrayBuffer));
 			eq(Type.getClass(vid), js.html.VideoElement);
 			eq(Type.getClass(vid), js.html.VideoElement);
 		}
 		}
 	}
 	}