diff --git a/core/src/avm2/globals/vector.rs b/core/src/avm2/globals/vector.rs index 80665f515..cb3a404a4 100644 --- a/core/src/avm2/globals/vector.rs +++ b/core/src/avm2/globals/vector.rs @@ -525,7 +525,7 @@ pub fn filter<'gc>( let value_type = this .as_class_object() - .and_then(|c| c.as_class_params().and_then(|p| p.get(0).copied())) + .and_then(|c| c.as_class_params()) .ok_or("Cannot filter unparameterized vector")? .unwrap_or(activation.avm2().classes().object); let mut new_storage = VectorStorage::new(0, false, value_type); @@ -684,7 +684,7 @@ pub fn map<'gc>( let value_type = this .as_class_object() - .and_then(|c| c.as_class_params().and_then(|p| p.get(0).copied())) + .and_then(|c| c.as_class_params()) .ok_or("Cannot filter unparameterized vector")? .unwrap_or(activation.avm2().classes().object); let mut new_storage = VectorStorage::new(0, false, value_type); diff --git a/core/src/avm2/object.rs b/core/src/avm2/object.rs index 826fdf7da..7f778c208 100644 --- a/core/src/avm2/object.rs +++ b/core/src/avm2/object.rs @@ -1042,25 +1042,21 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into> + Clone + Copy } } - if let (Some(my_params), Some(test_params)) = + if let (Some(my_param), Some(test_param)) = (class.as_class_params(), test_class.as_class_params()) { - if my_params.len() == test_params.len() { - let mut are_all_params_coercible = true; + let mut are_all_params_coercible = true; - for (my_param, test_param) in my_params.iter().zip(test_params.iter()) { - are_all_params_coercible &= match (my_param, test_param) { - (Some(my_param), Some(test_param)) => { - my_param.has_class_in_chain(*test_param, activation)? - } - (None, Some(_)) => false, - _ => true, - } + are_all_params_coercible &= match (my_param, test_param) { + (Some(my_param), Some(test_param)) => { + my_param.has_class_in_chain(test_param, activation)? } + (None, Some(_)) => false, + _ => true, + }; - if are_all_params_coercible { - return Ok(true); - } + if are_all_params_coercible { + return Ok(true); } } @@ -1082,7 +1078,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into> + Clone + Copy /// Get the parameters of this class object, if present. /// /// Only specialized generic classes will yield their parameters. - fn as_class_params(&self) -> Option>]>> { + fn as_class_params(&self) -> Option>> { None } diff --git a/core/src/avm2/object/class_object.rs b/core/src/avm2/object/class_object.rs index 40400ae9e..fbf7da74e 100644 --- a/core/src/avm2/object/class_object.rs +++ b/core/src/avm2/object/class_object.rs @@ -13,7 +13,6 @@ use crate::avm2::value::Value; use crate::avm2::Error; use crate::{impl_avm2_custom_object, impl_avm2_custom_object_properties}; use gc_arena::{Collect, GcCell, MutationContext}; -use std::cell::Ref; use std::collections::HashMap; /// An Object which can be called to execute its function code. @@ -54,7 +53,7 @@ pub struct ClassObjectData<'gc> { /// /// An individual parameter of `None` signifies the parameter `*`, which is /// represented in AVM2 as `null` with regards to type application. - params: Option>>>, + params: Option>>, /// List of all applications of this class. /// @@ -478,14 +477,8 @@ impl<'gc> TObject<'gc> for ClassObject<'gc> { None //AS3 does not have metaclasses } - fn as_class_params(&self) -> Option>]>> { - let read = self.0.read(); - - if read.params.is_some() { - Some(Ref::map(read, |r| &r.params.as_ref().unwrap()[..])) - } else { - None - } + fn as_class_params(&self) -> Option>> { + self.0.read().params } fn set_class_object(self, _mc: MutationContext<'gc, '_>, _class_object: Object<'gc>) { @@ -607,7 +600,7 @@ impl<'gc> TObject<'gc> for ClassObject<'gc> { instance_allocator, constructor, native_constructor, - params: Some(object_params.to_vec()), + params: Some(object_params[0]), applications: HashMap::new(), }, )); diff --git a/core/src/avm2/object/vector_object.rs b/core/src/avm2/object/vector_object.rs index c8a33b331..6ba5db3f4 100644 --- a/core/src/avm2/object/vector_object.rs +++ b/core/src/avm2/object/vector_object.rs @@ -27,7 +27,6 @@ pub fn vector_allocator<'gc>( //getting the parameter type for our storage. let param_type = class .as_class_params() - .and_then(|p| p.get(0).copied()) .flatten() .unwrap_or_else(|| activation.avm2().classes().object);