Merge pull request #1174 from FunkinCrew/bugfix/html5-reflectutil-nullsafety

This commit is contained in:
Kade
2025-06-11 17:36:40 -07:00
committed by GitHub
2 changed files with 19 additions and 4 deletions
+2
View File
@@ -255,6 +255,8 @@ class InitState extends FlxState
funkin.input.Cursor.hide();
#if !html5
// This fucking breaks on HTML5 builds because the "shared" library isn't loaded yet.
funkin.FunkinMemory.initialCache();
}
+17 -4
View File
@@ -7,6 +7,7 @@ import Type.ValueType;
* Used for sandboxing in scripts.
*/
@:nullSafety
@SuppressWarnings("checkstyle:VarTypeHint")
class ReflectUtil
{
/**
@@ -360,7 +361,11 @@ class ReflectUtil
*/
public static function getClassFieldsOf(obj:Any):Array<String>
{
return Type.getClassFields(Type.getClass(obj));
if (obj == null) return [];
@:nullSafety(Off)
var cls = Type.getClass(obj);
if (cls == null) return [];
return Type.getClassFields(cls);
}
/**
@@ -380,7 +385,11 @@ class ReflectUtil
*/
public static function getInstanceFieldsOf(obj:Any):Array<String>
{
return Type.getInstanceFields(Type.getClass(obj));
if (obj == null) return [];
@:nullSafety(Off)
var cls = Type.getClass(obj);
if (cls == null) return [];
return Type.getInstanceFields(cls);
}
/**
@@ -396,10 +405,14 @@ class ReflectUtil
/**
* Get the string name of the class of the given object.
* @param obj The object to query.
* @return The name of the given class.
* @return The name of the given class, or `Unknown` if the class couldn't be determined.
*/
public static function getClassNameOf(obj:Any):String
{
return Type.getClassName(Type.getClass(obj));
if (obj == null) return "Unknown";
@:nullSafety(Off)
var cls = Type.getClass(obj);
if (cls == null) return "Unknown";
return Type.getClassName(cls);
}
}