@@ -17,6 +17,7 @@ use super::{
1717 Array , BuiltInBuilder , BuiltInConstructor , Date , IntrinsicObject , RegExp , error:: Error ,
1818} ;
1919use crate :: builtins:: function:: arguments:: { MappedArguments , UnmappedArguments } ;
20+ use crate :: property:: CompletePropertyDescriptor ;
2021use crate :: value:: JsVariant ;
2122use crate :: {
2223 Context , JsArgs , JsData , JsExpect , JsResult , JsString ,
@@ -36,7 +37,6 @@ use crate::{
3637} ;
3738use boa_gc:: { Finalize , Trace } ;
3839use boa_macros:: js_str;
39- use tap:: { Conv , Pipe } ;
4040
4141pub ( crate ) mod for_in_iterator;
4242#[ cfg( test) ]
@@ -378,8 +378,8 @@ impl OrdinaryObject {
378378 // b. If desc is not undefined, then
379379 if let Some ( current_desc) = desc {
380380 // i. If IsAccessorDescriptor(desc) is true, return desc.[[Get]].
381- return if current_desc . is_accessor_descriptor ( ) {
382- Ok ( current_desc . expect_get ( ) . clone ( ) )
381+ return if let CompletePropertyDescriptor :: Accessor { get , .. } = current_desc {
382+ Ok ( get . map ( JsValue :: new ) . unwrap_or_default ( ) )
383383 } else {
384384 // ii. Return undefined.
385385 Ok ( JsValue :: undefined ( ) )
@@ -424,8 +424,8 @@ impl OrdinaryObject {
424424 // b. If desc is not undefined, then
425425 if let Some ( current_desc) = desc {
426426 // i. If IsAccessorDescriptor(desc) is true, return desc.[[Set]].
427- return if current_desc . is_accessor_descriptor ( ) {
428- Ok ( current_desc . expect_set ( ) . clone ( ) )
427+ return if let CompletePropertyDescriptor :: Accessor { set , .. } = current_desc {
428+ Ok ( set . map ( JsValue :: new ) . unwrap_or_default ( ) )
429429 } else {
430430 // ii. Return undefined.
431431 Ok ( JsValue :: undefined ( ) )
@@ -506,7 +506,7 @@ impl OrdinaryObject {
506506 obj. __get_own_property__ ( & key, & mut InternalMethodPropertyContext :: new ( context) ) ?;
507507
508508 // 4. Return FromPropertyDescriptor(desc).
509- Self :: from_property_descriptor ( desc, context)
509+ Self :: from_property_descriptor ( desc. map ( Into :: into ) , context)
510510 }
511511
512512 /// `Object.getOwnPropertyDescriptors( object )`
@@ -542,7 +542,8 @@ impl OrdinaryObject {
542542 obj. __get_own_property__ ( & key, & mut InternalMethodPropertyContext :: new ( context) ) ?;
543543
544544 // b. Let descriptor be FromPropertyDescriptor(desc).
545- let descriptor = Self :: from_property_descriptor ( desc, context) ?;
545+ let descriptor = Self :: from_property_descriptor ( desc. map ( Into :: into) , context)
546+ . expect ( "should never fail" ) ;
546547
547548 // c. If descriptor is not undefined,
548549 // perform ! CreateDataPropertyOrThrow(descriptors, key, descriptor).
@@ -942,12 +943,10 @@ impl OrdinaryObject {
942943 . to_object ( context) ?
943944 . __get_own_property__ ( & key, & mut InternalMethodPropertyContext :: new ( context) ) ?;
944945
945- own_prop
946+ Ok ( own_prop
946947 . as_ref ( )
947- . and_then ( PropertyDescriptor :: enumerable)
948- . unwrap_or_default ( )
949- . conv :: < JsValue > ( )
950- . pipe ( Ok )
948+ . is_some_and ( CompletePropertyDescriptor :: enumerable)
949+ . into ( ) )
951950 }
952951
953952 /// `Object.assign( target, ...sources )`
@@ -990,7 +989,7 @@ impl OrdinaryObject {
990989 & mut InternalMethodPropertyContext :: new ( context) ,
991990 ) ? {
992991 // 3.a.iii.2. If desc is not undefined and desc.[[Enumerable]] is true, then
993- if desc. expect_enumerable ( ) {
992+ if desc. enumerable ( ) {
994993 // 3.a.iii.2.a. Let propValue be ? Get(from, nextKey).
995994 let property = from. get ( key. clone ( ) , context) ?;
996995 // 3.a.iii.2.b. Perform ? Set(to, nextKey, propValue, true).
@@ -1458,7 +1457,7 @@ fn object_define_properties(
14581457
14591458 if let Some ( prop_desc) = props
14601459 . __get_own_property__ ( & next_key, & mut InternalMethodPropertyContext :: new ( context) ) ?
1461- && prop_desc. expect_enumerable ( )
1460+ && prop_desc. enumerable ( )
14621461 {
14631462 // i. Let descObj be ? Get(props, nextKey).
14641463 let desc_obj = props. get ( next_key. clone ( ) , context) ?;
0 commit comments