1/* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16class nonSendableClass9 {} 17 18@Sendable 19class SendableClass9 {} 20 21@Sendable 22class SendableClass10<T> { 23 prop1: number | null = {a: 1}; // OK 24 prop2: string | bigint | null = [1, 2]; // OK 25 prop3: SendableClass9 = {a: 1}; // ERROR, the initialization for "Sendable" objects is limited 26 prop4: SendableClass9 = [1, 2]; // ERROR, the initialization for "Sendable" objects is limited 27 prop5: SendableClass9 | T | BigInt = {a: 1}; // ERROR, the initialization for "Sendable" objects is limited 28 prop6: SendableClass9 | T | BigInt = [1, 2]; // ERROR, the initialization for "Sendable" objects is limited 29} 30 31let v0: string | nonSendableClass9 | undefined | null = {a: 1}; // OK 32let v1: undefined | nonSendableClass9 | null = [1, 2]; // OK 33let v2: SendableClass9 = {a: 1}; // ERROR, the initialization for "Sendable" objects is limited 34let v3: SendableClass9 = [1, 2]; // ERROR, the initialization for "Sendable" objects is limited 35let v4: SendableClass9 | nonSendableClass9 | BigInt = [1, 2]; // ERROR, the initialization for "Sendable" objects is limited 36let v5: SendableClass9 | nonSendableClass9 | null = [1, 2]; // ERROR, the initialization for "Sendable" objects is limited