avm2: Fix getQualifiedClassName for null and undefined

This commit is contained in:
Aaron Hill 2022-09-26 21:54:10 -05:00
parent 66fa67cdcc
commit 53f42e0bec
4 changed files with 15 additions and 6 deletions

View File

@ -193,10 +193,14 @@ pub fn get_qualified_class_name<'gc>(
_this: Option<Object<'gc>>,
args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
let obj = args
.get(0)
.unwrap_or(&Value::Undefined)
.coerce_to_object(activation)?;
// This is a native method, which enforces the argument count.
let val = args[0];
match val {
Value::Null => return Ok("null".into()),
Value::Undefined => return Ok("void".into()),
_ => {}
}
let obj = val.coerce_to_object(activation)?;
let class = match obj.as_class_object() {
Some(class) => class,

View File

@ -20,4 +20,7 @@ trace(getQualifiedClassName(String));
trace(getQualifiedClassName(new flash.utils.ByteArray()));
trace(getQualifiedClassName(new String()));
trace(getQualifiedClassName(new String()));
trace(getQualifiedClassName(null));
trace(getQualifiedClassName(undefined));

View File

@ -5,4 +5,6 @@ com.very.long.namespace::example
int
String
flash.utils::ByteArray
String
String
null
void