Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null-safe Type.getClass #11115

Merged
merged 1 commit into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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