diff --git a/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp b/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp index 1d889dee82cc474350eedfaf5af4ae16eda1df56..954ab385733b2961e7fe6ffb4ffaf908ae5b67dd 100644 --- a/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp +++ b/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp @@ -375,7 +375,8 @@ static void HandleInterfaceLowering(public_lib::Context *ctx, ir::ObjectExpressi resultType = instantiationCtx.Result(); } - if (const auto *const parent = objExpr->Parent(); parent->IsArrayExpression()) { + if (const auto *const parent = objExpr->Parent(); + parent->IsArrayExpression() && !parent->AsArrayExpression()->TsType()->IsETSTupleType()) { for (auto *elem : parent->AsArrayExpression()->Elements()) { if (elem->IsObjectExpression()) { elem->AsObjectExpression()->SetTsType(resultType); diff --git a/ets2panda/test/runtime/ets/HandleInterfaceLowering_tuplerroe.ets b/ets2panda/test/runtime/ets/HandleInterfaceLowering_tuplerroe.ets new file mode 100644 index 0000000000000000000000000000000000000000..aa7d2be563201ad82d937f4e9c78d90c05d84e8d --- /dev/null +++ b/ets2panda/test/runtime/ets/HandleInterfaceLowering_tuplerroe.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +interface ReadOnlyValue { + readonly value: number; +} +interface ReadOnlyName { + readonly name: string; +} + +type MappedTuple = [ReadOnlyValue, ReadOnlyName]; + +function main(): void { + let tuple: MappedTuple = [ + { value: 42 }, + { name: 'Alice' } + ]; + + arktest.assertEQ(tuple[0].value, 42); + arktest.assertEQ(tuple[1].name, 'Alice'); +} \ No newline at end of file