diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index 80da256ea0771cff34142b2c037396d5e33ce787..ee0114c5d286a2096f020cfa5034ff7976e3a36e 100644 --- a/ets2panda/checker/ETSAnalyzer.cpp +++ b/ets2panda/checker/ETSAnalyzer.cpp @@ -1116,6 +1116,21 @@ void TryInferPreferredType(ir::ArrowFunctionExpression *expr, checker::Type *pre } } +static bool IsUnionTypeContainingPromise(checker::Type *type, ETSChecker *checker) +{ + if (!type->IsETSUnionType()) { + return false; + } + for (auto subtype : type->AsETSUnionType()->ConstituentTypes()) { + if (subtype->IsETSObjectType() && + subtype->AsETSObjectType()->GetOriginalBaseType() == checker->GlobalBuiltinPromiseType()) { + return true; + } + } + + return false; +} + checker::Type *ETSAnalyzer::Check(ir::ArrowFunctionExpression *expr) const { ETSChecker *checker = GetETSChecker(); @@ -1177,8 +1192,9 @@ checker::Type *ETSAnalyzer::Check(ir::ArrowFunctionExpression *expr) const if (expr->Function()->ReturnTypeAnnotation() == nullptr) { if (expr->Function()->IsAsyncFunc()) { auto *retType = signature->ReturnType(); - if (!retType->IsETSObjectType() || - retType->AsETSObjectType()->GetOriginalBaseType() != checker->GlobalBuiltinPromiseType()) { + if (!IsUnionTypeContainingPromise(retType, checker) && + (!retType->IsETSObjectType() || + retType->AsETSObjectType()->GetOriginalBaseType() != checker->GlobalBuiltinPromiseType())) { auto returnType = checker->CreateETSAsyncFuncReturnTypeFromBaseType(signature->ReturnType()); ES2PANDA_ASSERT(returnType != nullptr); expr->Function()->Signature()->SetReturnType(returnType->PromiseType()); diff --git a/ets2panda/checker/ets/object.cpp b/ets2panda/checker/ets/object.cpp index f0869bbb568a3387e1809b3878506e8c004c1cf4..c9f84099333ac32174502e1337303c2a71e50e5d 100644 --- a/ets2panda/checker/ets/object.cpp +++ b/ets2panda/checker/ets/object.cpp @@ -1120,6 +1120,10 @@ void ETSChecker::ValidateNonOverriddenFunction(ETSObjectType *classType, ArenaVe auto superClassType = classType->SuperType(); while (!functionOverridden && superClassType != nullptr) { for (auto *field : superClassType->Fields()) { + if (field->Declaration()->Node()->AsClassProperty()->IsStatic()) { + continue; + } + if (field->Name() == (*it)->Name()) { auto *newProp = field->Declaration() ->Node() diff --git a/ets2panda/test/ast/compiler/ets/interface_class_implement_extend.ets b/ets2panda/test/ast/compiler/ets/interface_class_implement_extend.ets new file mode 100644 index 0000000000000000000000000000000000000000..afa9486646466460e5f108d2f3bd33d13a6725d4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/interface_class_implement_extend.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023-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 AA { + X :int; +} +class A implements AA{ + static X :int=1; +} +class extendA extends A{ + +} + +/* @@? 19:22 Error TypeError: A is not abstract and does not implement getter for X property in AA */ +/* @@? 22:24 Error TypeError: extendA is not abstract and does not implement getter for X property in AA */ diff --git a/ets2panda/test/runtime/ets/async_lambda_return_type_test.ets b/ets2panda/test/runtime/ets/async_lambda_return_type_test.ets new file mode 100644 index 0000000000000000000000000000000000000000..71a3cec3a5ba46a1de8dd03aea6656239cf65406 --- /dev/null +++ b/ets2panda/test/runtime/ets/async_lambda_return_type_test.ets @@ -0,0 +1,30 @@ +/* + * 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. + */ + +let money_box: number[] = Array.from([10.0, 5.0, 20.0, 50.0, 100.0, 200.0, 500.0]) +let lock: AsyncLock = AsyncLock.request("lock_1") +let len: number = 0 + +async function initialize() { + len = await lock.lockAsync(async () => { + return money_box.length + }) +} + +function main() { + initialize().then(() => { + arktest.assertEQ(len, 7) + }) +} diff --git a/ets2panda/test/test-lists/declgenets2ts/ets-runtime/declgen-ets2ts-runtime-ignored.txt b/ets2panda/test/test-lists/declgenets2ts/ets-runtime/declgen-ets2ts-runtime-ignored.txt index 91e2b0af730ae0cd8eb48da252d759b2eda18c8d..4444cd873b3219913e341f394f3a026e272d21e9 100644 --- a/ets2panda/test/test-lists/declgenets2ts/ets-runtime/declgen-ets2ts-runtime-ignored.txt +++ b/ets2panda/test/test-lists/declgenets2ts/ets-runtime/declgen-ets2ts-runtime-ignored.txt @@ -29,3 +29,4 @@ fuzz/too_many_async.ets typeAlias_2.ets Multiline_string.ets Multiline_string_escape_char.ets +async_lambda_return_type_test.ets