diff --git a/ets2panda/checker/types/ets/etsObjectType.cpp b/ets2panda/checker/types/ets/etsObjectType.cpp index 1d42b6745b67e535f5e49972712ccb531f04eec8..32f5f8f46fa472a34e7d0b697dacf753b205683a 100644 --- a/ets2panda/checker/types/ets/etsObjectType.cpp +++ b/ets2panda/checker/types/ets/etsObjectType.cpp @@ -648,15 +648,14 @@ void ETSObjectType::SubstitutePartialTypes(TypeRelation *relation, Type *other) void ETSObjectType::IdenticalUptoTypeArguments(TypeRelation *relation, Type *other) { relation->Result(false); + if (!other->IsETSObjectType() || !CheckIdenticalFlags(other->AsETSObjectType())) { + return; + } if (IsPartial()) { SubstitutePartialTypes(relation, other); } - if (!other->IsETSObjectType() || !CheckIdenticalFlags(other->AsETSObjectType())) { - return; - } - // NOTE: (DZ) only both Partial types can be compatible. if (static_cast(static_cast(IsPartial()) ^ static_cast(other->AsETSObjectType()->IsPartial()))) { diff --git a/ets2panda/test/ast/compiler/ets/union_type_of_partial_type.ets b/ets2panda/test/ast/compiler/ets/union_type_of_partial_type.ets new file mode 100644 index 0000000000000000000000000000000000000000..b024428363cc3f69df19ac62f9c781c0332e5f3f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/union_type_of_partial_type.ets @@ -0,0 +1,28 @@ +/* + * 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: * + * 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. + */ + +abstract class A>{ + foo({ }, init: Partial | undefined): void { + } +} + +/* @@? 16:9 Error SyntaxError: Unexpected token, expected an identifier. */ +/* @@? 16:9 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ +/* @@? 16:9 Error SyntaxError: Unexpected token, expected ',' or ')'. */ +/* @@? 16:12 Error SyntaxError: Unexpected token ','. */ +/* @@? 16:42 Error SyntaxError: Unexpected token ')'. */ +/* @@? 16:43 Error SyntaxError: Unexpected token ':'. */ +/* @@? 16:45 Error SyntaxError: void is a predefined type, cannot be used as an identifier */ +/* @@? 16:50 Error SyntaxError: Unexpected token '{'. */ +/* @@? 18:1 Error SyntaxError: Unexpected token '}'. */