From ac83c3422d211740c333745b15fb5d16a6639143 Mon Sep 17 00:00:00 2001 From: Mingyang Date: Wed, 30 Jul 2025 10:29:41 +0800 Subject: [PATCH] Fix CreateNullishProperty propClone added tsType Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICPPK7 Reason: The compiler crashed in `unboxLowering` due to `prop->Key()->Variable()->TsType()` being null. Description: In `ETSChecker::CreateNullishProperty`, if `propClone->TsType()` is not `nullptr`, it will skip some steps and leave `prop->Key()->Variable()->TsType()` as `nullptr`. Therefore, in `ETSChecker::CreateNullishProperty::328`, clone's TsType should be cleaned by `clone->CleanCheckInformation()`. 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 passed Signed-off-by: Mingyang --- ets2panda/checker/ets/utilityTypeHandlers.cpp | 1 + .../ets/AnnotationOfExportClassProperty.ets | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 ets2panda/test/runtime/ets/AnnotationOfExportClassProperty.ets diff --git a/ets2panda/checker/ets/utilityTypeHandlers.cpp b/ets2panda/checker/ets/utilityTypeHandlers.cpp index 93f6b5eccc..584958e790 100644 --- a/ets2panda/checker/ets/utilityTypeHandlers.cpp +++ b/ets2panda/checker/ets/utilityTypeHandlers.cpp @@ -325,6 +325,7 @@ ir::ClassProperty *ETSChecker::CreateNullishProperty(ir::ClassProperty *const pr prop->SetValue(nullptr); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const propClone = prop->Clone(ProgramAllocator(), newClassDefinition)->AsClassProperty(); + propClone->CleanCheckInformation(); // Revert original property value prop->SetValue(propSavedValue); diff --git a/ets2panda/test/runtime/ets/AnnotationOfExportClassProperty.ets b/ets2panda/test/runtime/ets/AnnotationOfExportClassProperty.ets new file mode 100644 index 0000000000..89963cc447 --- /dev/null +++ b/ets2panda/test/runtime/ets/AnnotationOfExportClassProperty.ets @@ -0,0 +1,24 @@ +/* + * 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 SomeAnnotation { + field1: int = 1 +} + +@SomeAnnotation() +export class MyClass { + @SomeAnnotation() + field: int = 1 +} -- Gitee