From 06afaf1309cef5e4c1cb39409f7de41bec529992 Mon Sep 17 00:00:00 2001 From: Mingyang Date: Fri, 15 Aug 2025 15:44:16 +0800 Subject: [PATCH] Fix issue with interface and extend class Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICT6FR Reason: Program will crash when interface and extend class static type use the same name. Description: If class property is static, do the same for extend class as it does for regular class. Tests: ninja tests passed tests/tests-u-runner/runner.sh --ets-cts --show-progress --build-dir x64.release --processes=all passed tests/tests-u-runner/runner.sh --ets-func-tests --show-progress --build-dir x64.release --processes=all passed tests/tests-u-runner/runner.sh --astchecker --show-progress --build-dir x64.release --processes=all passed tests/tests-u-runner/runner.sh --ets-runtime --show-progress --build-dir x64.release --processes=all passed tests/tests-u-runner/runner.sh --parser --no-js --show-progress --build-dir x64.release --processes=all passe Signed-off-by: Mingyang --- ets2panda/checker/ets/object.cpp | 4 +++ .../ets/interface_class_implement_extend.ets | 27 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 ets2panda/test/ast/compiler/ets/interface_class_implement_extend.ets diff --git a/ets2panda/checker/ets/object.cpp b/ets2panda/checker/ets/object.cpp index 7303f27a93..ca61ee9e58 100644 --- a/ets2panda/checker/ets/object.cpp +++ b/ets2panda/checker/ets/object.cpp @@ -1122,6 +1122,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 0000000000..afa9486646 --- /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 */ -- Gitee