From 89b282b7ba5fbc00b41bcc8022da63c9360108ff Mon Sep 17 00:00:00 2001 From: xuxinjie4 Date: Fri, 25 Jul 2025 11:45:24 +0800 Subject: [PATCH] Fix crash when create PartialType Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICORHR?from=project-issue Signed-off-by: xuxinjie4 --- ets2panda/checker/ets/utilityTypeHandlers.cpp | 6 +---- .../ets/unresolve_class_with_type_infer.ets | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 ets2panda/test/ast/compiler/ets/unresolve_class_with_type_infer.ets diff --git a/ets2panda/checker/ets/utilityTypeHandlers.cpp b/ets2panda/checker/ets/utilityTypeHandlers.cpp index 1041ab4faf..35d8f7d50d 100644 --- a/ets2panda/checker/ets/utilityTypeHandlers.cpp +++ b/ets2panda/checker/ets/utilityTypeHandlers.cpp @@ -118,11 +118,7 @@ static T *CloneNodeIfNotNullptr(T *node, ArenaAllocator *allocator) Type *ETSChecker::CreatePartialType(Type *const typeToBePartial) { ES2PANDA_ASSERT(typeToBePartial->IsETSReferenceType()); - if (typeToBePartial->IsTypeError()) { - return typeToBePartial; - } - - if (typeToBePartial->IsETSAnyType()) { + if (typeToBePartial->IsTypeError() || typeToBePartial->IsETSNeverType() || typeToBePartial->IsETSAnyType()) { return typeToBePartial; } diff --git a/ets2panda/test/ast/compiler/ets/unresolve_class_with_type_infer.ets b/ets2panda/test/ast/compiler/ets/unresolve_class_with_type_infer.ets new file mode 100644 index 0000000000..9347301cc3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/unresolve_class_with_type_infer.ets @@ -0,0 +1,22 @@ +/* + * 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. + */ + +function foo>(record: Record>){ + +} + +foo({}) + +/* @@? 16:39 Error TypeError: Cannot find type 'A'. */ -- Gitee