From faa72e7fba96646bcdb4117d80e2e24e515952d6 Mon Sep 17 00:00:00 2001 From: yunusemrekarakaya Date: Thu, 19 Jun 2025 15:02:07 +0300 Subject: [PATCH] [Bug]: ErrorType Control Issue : https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICGGBG Signed-off-by: yunusemrekarakaya --- ets2panda/checker/ets/utilityTypeHandlers.cpp | 3 ++ ...ility_type_can_not_found_etsobjecttype.ets | 29 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 ets2panda/test/ast/compiler/ets/utility_type_can_not_found_etsobjecttype.ets diff --git a/ets2panda/checker/ets/utilityTypeHandlers.cpp b/ets2panda/checker/ets/utilityTypeHandlers.cpp index c267defa3c..ed297d6edd 100644 --- a/ets2panda/checker/ets/utilityTypeHandlers.cpp +++ b/ets2panda/checker/ets/utilityTypeHandlers.cpp @@ -118,6 +118,9 @@ 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()) { return typeToBePartial; diff --git a/ets2panda/test/ast/compiler/ets/utility_type_can_not_found_etsobjecttype.ets b/ets2panda/test/ast/compiler/ets/utility_type_can_not_found_etsobjecttype.ets new file mode 100644 index 0000000000..f549a860b8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/utility_type_can_not_found_etsobjecttype.ets @@ -0,0 +1,29 @@ +/* + * 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. + */ + +type BaseObject = Record; + +class X { + x: T; + + constructor(init?: Partial) { + + this.x = {} as T; + + } +} + +/* @@? 16:34 Error TypeError: Cannot find type 'any'. */ +/* @@? 23:14 Error TypeError: Target type for class composite needs to be an object type, found 'T' */ \ No newline at end of file -- Gitee