From 649d2cae81fe7233cafed22485225a87ece73165 Mon Sep 17 00:00:00 2001 From: RblSb Date: Sun, 9 Apr 2023 03:21:33 +0300 Subject: [PATCH] Null-safe Type.getClass --- std/Type.hx | 2 +- std/cpp/_std/Type.hx | 2 +- std/cs/_std/Type.hx | 2 +- std/flash/_std/Type.hx | 2 +- std/hl/_std/Type.hx | 2 +- std/java/_std/Type.hx | 2 +- std/js/_std/Type.hx | 2 +- std/jvm/_std/Type.hx | 2 +- std/lua/_std/Type.hx | 2 +- std/neko/_std/Type.hx | 2 +- std/php/_std/Type.hx | 2 +- std/python/_std/Type.hx | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/std/Type.hx b/std/Type.hx index 48e67b064ba..5d28f5c5435 100644 --- a/std/Type.hx +++ b/std/Type.hx @@ -37,7 +37,7 @@ extern class Type { In general, type parameter information cannot be obtained at runtime. **/ - static function getClass(o:T):Class; + static function getClass(o:T):Null>; /** Returns the enum of enum instance `o`. diff --git a/std/cpp/_std/Type.hx b/std/cpp/_std/Type.hx index 2b71193d33e..d0af410fe19 100644 --- a/std/cpp/_std/Type.hx +++ b/std/cpp/_std/Type.hx @@ -32,7 +32,7 @@ enum ValueType { } @:coreApi class Type { - public static function getClass(o:T):Class + public static function getClass(o:T):Null> untyped { if (o == null || !Reflect.isObject(o)) return null; diff --git a/std/cs/_std/Type.hx b/std/cs/_std/Type.hx index a55387da4a2..cfdd7410008 100644 --- a/std/cs/_std/Type.hx +++ b/std/cs/_std/Type.hx @@ -43,7 +43,7 @@ enum ValueType { } @:coreApi class Type { - public static function getClass(o:T):Class { + public static function getClass(o:T):Null> { if (Object.ReferenceEquals(o, null) || Std.isOfType(o, DynamicObject) || Std.isOfType(o, cs.system.Type)) return null; diff --git a/std/flash/_std/Type.hx b/std/flash/_std/Type.hx index c1e6e79fd68..5165b49af20 100644 --- a/std/flash/_std/Type.hx +++ b/std/flash/_std/Type.hx @@ -32,7 +32,7 @@ enum ValueType { } @:coreApi class Type { - public static function getClass(o:T):Class + public static function getClass(o:T):Null> untyped { var cname = __global__["flash.utils.getQualifiedClassName"](o); if (cname == "null" || cname == "Object" || cname == "int" || cname == "Number" || cname == "Boolean") diff --git a/std/hl/_std/Type.hx b/std/hl/_std/Type.hx index 8ac34543b83..1096f00f80b 100644 --- a/std/hl/_std/Type.hx +++ b/std/hl/_std/Type.hx @@ -82,7 +82,7 @@ class Type { allTypes.set(b, t); } - public static function getClass(o:T):Class { + public static function getClass(o:T):Null> { var t = hl.Type.getDynamic(o); if (t.kind == HVirtual) { o = hl.Api.getVirtualValue(o); diff --git a/std/java/_std/Type.hx b/std/java/_std/Type.hx index 6966fdd583b..a07ffd6562a 100644 --- a/std/java/_std/Type.hx +++ b/std/java/_std/Type.hx @@ -37,7 +37,7 @@ enum ValueType { } @:coreApi class Type { - public static function getClass(o:T):Class { + public static function getClass(o:T):Null> { if (o == null || Std.isOfType(o, DynamicObject) || Std.isOfType(o, java.lang.Class)) { return null; } diff --git a/std/js/_std/Type.hx b/std/js/_std/Type.hx index 50956606efa..695bba203b3 100644 --- a/std/js/_std/Type.hx +++ b/std/js/_std/Type.hx @@ -32,7 +32,7 @@ enum ValueType { } @:coreApi class Type { - public static inline function getClass(o:T):Class { + public static inline function getClass(o:T):Null> { return @:privateAccess js.Boot.getClass(o); } diff --git a/std/jvm/_std/Type.hx b/std/jvm/_std/Type.hx index d86d8aac912..957c2826e63 100644 --- a/std/jvm/_std/Type.hx +++ b/std/jvm/_std/Type.hx @@ -32,7 +32,7 @@ class Type { return c.isAnnotationPresent(cast EnumValueReflectionInformation); } - public static function getClass(o:T):Class { + public static function getClass(o:T):Null> { if (o == null) { return null; } diff --git a/std/lua/_std/Type.hx b/std/lua/_std/Type.hx index 6ef614a5d54..d9f658ecbfa 100644 --- a/std/lua/_std/Type.hx +++ b/std/lua/_std/Type.hx @@ -36,7 +36,7 @@ enum ValueType { } @:coreApi class Type { - public static function getClass(o:T):Class + public static function getClass(o:T):Null> untyped { if (o == null) return null; diff --git a/std/neko/_std/Type.hx b/std/neko/_std/Type.hx index 135b331ade0..6db1b3c5ffd 100644 --- a/std/neko/_std/Type.hx +++ b/std/neko/_std/Type.hx @@ -34,7 +34,7 @@ enum ValueType { @:coreApi class Type { - public static function getClass( o : T ) : Class untyped { + public static function getClass( o : T ) : Null> untyped { if( __dollar__typeof(o) != __dollar__tobject ) return null; var p = __dollar__objgetproto(o); diff --git a/std/php/_std/Type.hx b/std/php/_std/Type.hx index 1f762715482..6f85ef55ca7 100644 --- a/std/php/_std/Type.hx +++ b/std/php/_std/Type.hx @@ -39,7 +39,7 @@ enum ValueType { } @:coreApi class Type { - public static function getClass(o:T):Class { + public static function getClass(o:T):Null> { if (Global.is_object(o) && !Boot.isClass(o) && !Boot.isEnumValue(o)) { var cls = Boot.getClass(Global.get_class(cast o)); return (Boot.isAnon(o) ? null : cast cls); diff --git a/std/python/_std/Type.hx b/std/python/_std/Type.hx index 9321cbbf2af..3a434ccb258 100644 --- a/std/python/_std/Type.hx +++ b/std/python/_std/Type.hx @@ -40,7 +40,7 @@ enum ValueType { @:access(python.Boot) @:coreApi class Type { - public static function getClass(o:T):Class { + public static function getClass(o:T):Null> { if (o == null) return null;