diff --git a/ets2panda/checker/types/ets/etsTypeParameter.cpp b/ets2panda/checker/types/ets/etsTypeParameter.cpp index d19a6ef1162b28ee9fc728d3aad613230c6d612d..f747631ae6d5943844182b2e330607eb2db5f9b6 100644 --- a/ets2panda/checker/types/ets/etsTypeParameter.cpp +++ b/ets2panda/checker/types/ets/etsTypeParameter.cpp @@ -144,8 +144,7 @@ Type *ETSTypeParameter::Substitute(TypeRelation *relation, const Substitution *s if (this != original && ((ContainsNull() && !repl_type->ContainsNull()) || (ContainsUndefined() && !repl_type->ContainsUndefined()))) { // this type is explicitly marked as nullish - ASSERT(repl_type->IsETSObjectType() || repl_type->IsETSArrayType() || repl_type->IsETSFunctionType() || - repl_type->IsETSTypeParameter()); + ASSERT(ETSChecker::IsReferenceType(repl_type)); auto nullish_flags = TypeFlag(TypeFlags() & TypeFlag::NULLISH); auto *new_repl_type = checker->CreateNullishType(repl_type, nullish_flags, checker->Allocator(), relation, checker->GetGlobalTypesHolder()); diff --git a/ets2panda/test/runtime/ets/generic_constructor_with_union.ets b/ets2panda/test/runtime/ets/generic_constructor_with_union.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ec5964d829f315163a3b5cb5c75ebd0cdfeab1c --- /dev/null +++ b/ets2panda/test/runtime/ets/generic_constructor_with_union.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2023 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 main(): void { + let x = new Array<(Number|String)>(); +} \ No newline at end of file