Skip to content

Commit

Permalink
Null-safe Type.getClass (#11115)
Browse files Browse the repository at this point in the history
  • Loading branch information
RblSb authored Apr 11, 2023
1 parent ea162bc commit ee92125
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion std/Type.hx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extern class Type {
In general, type parameter information cannot be obtained at runtime.
**/
static function getClass<T>(o:T):Class<T>;
static function getClass<T>(o:T):Null<Class<T>>;

/**
Returns the enum of enum instance `o`.
Expand Down
2 changes: 1 addition & 1 deletion std/cpp/_std/Type.hx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ enum ValueType {
}

@:coreApi class Type {
public static function getClass<T>(o:T):Class<T>
public static function getClass<T>(o:T):Null<Class<T>>
untyped {
if (o == null || !Reflect.isObject(o))
return null;
Expand Down
2 changes: 1 addition & 1 deletion std/cs/_std/Type.hx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ enum ValueType {
}

@:coreApi class Type {
public static function getClass<T>(o:T):Class<T> {
public static function getClass<T>(o:T):Null<Class<T>> {
if (Object.ReferenceEquals(o, null) || Std.isOfType(o, DynamicObject) || Std.isOfType(o, cs.system.Type))
return null;

Expand Down
2 changes: 1 addition & 1 deletion std/flash/_std/Type.hx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ enum ValueType {
}

@:coreApi class Type {
public static function getClass<T>(o:T):Class<T>
public static function getClass<T>(o:T):Null<Class<T>>
untyped {
var cname = __global__["flash.utils.getQualifiedClassName"](o);
if (cname == "null" || cname == "Object" || cname == "int" || cname == "Number" || cname == "Boolean")
Expand Down
2 changes: 1 addition & 1 deletion std/hl/_std/Type.hx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Type {
allTypes.set(b, t);
}

public static function getClass<T>(o:T):Class<T> {
public static function getClass<T>(o:T):Null<Class<T>> {
var t = hl.Type.getDynamic(o);
if (t.kind == HVirtual) {
o = hl.Api.getVirtualValue(o);
Expand Down
2 changes: 1 addition & 1 deletion std/java/_std/Type.hx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ enum ValueType {
}

@:coreApi class Type {
public static function getClass<T>(o:T):Class<T> {
public static function getClass<T>(o:T):Null<Class<T>> {
if (o == null || Std.isOfType(o, DynamicObject) || Std.isOfType(o, java.lang.Class)) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion std/js/_std/Type.hx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ enum ValueType {
}

@:coreApi class Type {
public static inline function getClass<T>(o:T):Class<T> {
public static inline function getClass<T>(o:T):Null<Class<T>> {
return @:privateAccess js.Boot.getClass(o);
}

Expand Down
2 changes: 1 addition & 1 deletion std/jvm/_std/Type.hx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Type {
return c.isAnnotationPresent(cast EnumValueReflectionInformation);
}

public static function getClass<T>(o:T):Class<T> {
public static function getClass<T>(o:T):Null<Class<T>> {
if (o == null) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion std/lua/_std/Type.hx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ enum ValueType {
}

@:coreApi class Type {
public static function getClass<T>(o:T):Class<T>
public static function getClass<T>(o:T):Null<Class<T>>
untyped {
if (o == null)
return null;
Expand Down
2 changes: 1 addition & 1 deletion std/neko/_std/Type.hx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ enum ValueType {

@:coreApi class Type {

public static function getClass<T>( o : T ) : Class<T> untyped {
public static function getClass<T>( o : T ) : Null<Class<T>> untyped {
if( __dollar__typeof(o) != __dollar__tobject )
return null;
var p = __dollar__objgetproto(o);
Expand Down
2 changes: 1 addition & 1 deletion std/php/_std/Type.hx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ enum ValueType {
}

@:coreApi class Type {
public static function getClass<T>(o:T):Class<T> {
public static function getClass<T>(o:T):Null<Class<T>> {
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);
Expand Down
2 changes: 1 addition & 1 deletion std/python/_std/Type.hx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ enum ValueType {

@:access(python.Boot)
@:coreApi class Type {
public static function getClass<T>(o:T):Class<T> {
public static function getClass<T>(o:T):Null<Class<T>> {
if (o == null)
return null;

Expand Down

0 comments on commit ee92125

Please sign in to comment.