From 6a453bc29062e87f9c86b76098d07c121967a883 Mon Sep 17 00:00:00 2001 From: lhc Date: Tue, 2 Sep 2025 17:23:28 +0800 Subject: [PATCH] From interface of SendableArray returns no SendableArray Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/ICW0Y7?from=project-issue Signed-off-by: lhc Change-Id: I79cf695093a09c346fc4165bcb3a0a9c3b45dfef --- ecmascript/builtins/builtins_shared_array.cpp | 18 ++++-------------- test/sharedtest/sendableobj/expect_output.txt | 3 ++- test/sharedtest/sendableobj/sendable.ts | 8 ++++++++ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/ecmascript/builtins/builtins_shared_array.cpp b/ecmascript/builtins/builtins_shared_array.cpp index 947713c4ff..b7c989669b 100644 --- a/ecmascript/builtins/builtins_shared_array.cpp +++ b/ecmascript/builtins/builtins_shared_array.cpp @@ -261,15 +261,6 @@ JSTaggedValue BuiltinsSharedArray::From(EcmaRuntimeCallInfo *argv) JSHandle undefined = thread->GlobalConstants()->GetHandledUndefined(); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); if (!usingIterator->IsUndefined()) { - // Fast path for MapIterator - JSHandle iterator(thread, JSTaggedValue::Hole()); - if (!mapping && items->IsJSMapIterator()) { - iterator = JSIterator::GetIterator(thread, items, usingIterator); - if (iterator->IsJSMapIterator()) { - return JSMapIterator::MapIteratorToList(thread, iterator); - } - } - // a. If IsConstructor(C) is true, then // i. Let A be Construct(C). // b. Else, @@ -291,11 +282,10 @@ JSTaggedValue BuiltinsSharedArray::From(EcmaRuntimeCallInfo *argv) } JSHandle newArrayHandle(thread, newArray); // d. Let iterator be GetIterator(items, usingIterator). - if (iterator->IsHole()) { - iterator = JSIterator::GetIterator(thread, items, usingIterator); - // e. ReturnIfAbrupt(iterator). - RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - } + JSHandle iterator(thread, JSTaggedValue::Hole()); + iterator = JSIterator::GetIterator(thread, items, usingIterator); + // e. ReturnIfAbrupt(iterator). + RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); // f. Let k be 0. int k = 0; // g. Repeat diff --git a/test/sharedtest/sendableobj/expect_output.txt b/test/sharedtest/sendableobj/expect_output.txt index 63ca9d9a46..0578d756f7 100644 --- a/test/sharedtest/sendableobj/expect_output.txt +++ b/test/sharedtest/sendableobj/expect_output.txt @@ -19,4 +19,5 @@ string is sendable number is sendable bigInt is sendable function is not sendable -sendableFunc is sendable \ No newline at end of file +sendableFunc is sendable +Arr is sendable \ No newline at end of file diff --git a/test/sharedtest/sendableobj/sendable.ts b/test/sharedtest/sendableobj/sendable.ts index 70fba31267..f7cccd968b 100644 --- a/test/sharedtest/sendableobj/sendable.ts +++ b/test/sharedtest/sendableobj/sendable.ts @@ -97,3 +97,11 @@ if (isSendable(func)) { print("sendableFunc is not sendable"); } +let sharedMap: SendableMap = new SendableMap(); +sharedMap.set(4, "value4"); +let arr = SendableArray.from(sharedMap.keys()); +if (isSendable(arr)) { + print("Arr is sendable"); +} else { + print("Arr is not sendable"); +} -- Gitee