From 636b4f960ed1d546b8b6a3ed50424ffcec68a4a7 Mon Sep 17 00:00:00 2001 From: daizihan Date: Mon, 7 Jul 2025 21:46:15 +0800 Subject: [PATCH] Fix fuzz crash Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICKLXR?from=project-issue Signed-off-by: daizihan --- ets2panda/checker/ets/utilityTypeHandlers.cpp | 3 +++ .../test/ast/compiler/ets/fuzzingtest6.ets | 25 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 ets2panda/test/ast/compiler/ets/fuzzingtest6.ets diff --git a/ets2panda/checker/ets/utilityTypeHandlers.cpp b/ets2panda/checker/ets/utilityTypeHandlers.cpp index 0224e9882e..107f18115f 100644 --- a/ets2panda/checker/ets/utilityTypeHandlers.cpp +++ b/ets2panda/checker/ets/utilityTypeHandlers.cpp @@ -886,6 +886,9 @@ Type *ETSChecker::CreatePartialTypeClassDef(ir::ClassDefinition *const partialCl LogError(diagnostic::CYCLIC_CLASS_SUPER_TYPE, {}, classDef->Start()); return partialType; } + if (partialSuper->IsTypeError()) { + return partialType; + } partialType->SetSuperType(partialSuper->AsETSObjectType()); } diff --git a/ets2panda/test/ast/compiler/ets/fuzzingtest6.ets b/ets2panda/test/ast/compiler/ets/fuzzingtest6.ets new file mode 100644 index 0000000000..79c7af6977 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/fuzzingtest6.ets @@ -0,0 +1,25 @@ +/* + * 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 inter { } + +class B extends A implements inter { +} + +function foo1(b: Partial>) { +} + +/* @@? 18:20 Error TypeError: Cannot find type 'A'. */ +/* @@? 18:20 Error TypeError: The super type of 'B' class is not extensible. */ -- Gitee