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 16/* 17 * @tc.name:sendableclassuseimport 18 * @tc.desc:test sendableclassuseimport 19 * @tc.type: FUNC 20 * @tc.require: issue#IB6QMB 21 */ 22 23// @ts-nocheck 24declare function print(str: any): string; 25export class SendableLocalClass { 26 constructor() { 27 "use sendable"; 28 } 29 func(tag : string) { 30 print("SendableLocalClass, " + tag); 31 } 32} 33 34export function sendableLocalFunc(tag : string) { 35 "use sendable"; 36 print("sendableLocalFunc, " + tag); 37} 38export function localFunc(tag : string) { 39 print("localFunc, " + tag); 40} 41export class LocalClass { 42 func(tag : string) { 43 print("LocalClass, " + tag); 44 } 45} 46export class SendableUseLocalModuleValue { 47 constructor() { 48 "use sendable"; 49 } 50 start() { 51 new SendableLocalClass().func("SendableUseLocalModuleValue::start"); 52 sendableLocalFunc("SendableUseLocalModuleValue::start"); 53 new LocalClass().func("SendableUseLocalModuleValue::start"); 54 localFunc("SendableUseLocalModuleValue::start"); 55 } 56 static { 57 new SendableLocalClass().func("SendableUseLocalModuleValue::static block"); 58 sendableLocalFunc("SendableUseLocalModuleValue::static block"); 59 new LocalClass().func("SendableUseLocalModuleValue::static block"); 60 localFunc("SendableUseLocalModuleValue::static block"); 61 class InStaticSendableClass { 62 constructor() { 63 "use sendable"; 64 } 65 foo() { 66 new SendableLocalClass().func("InStaticSendableClass::foo"); 67 sendableLocalFunc("InStaticSendableClass::foo"); 68 new LocalClass().func("InStaticSendableClass::foo"); 69 localFunc("InStaticSendableClass::foo"); 70 } 71 } 72 new InStaticSendableClass().foo() 73 class InStaticClass { 74 foo() { 75 new SendableLocalClass().func("InStaticClass::foo"); 76 sendableLocalFunc("InStaticClass::foo"); 77 new LocalClass().func("InStaticClass::foo"); 78 localFunc("InStaticClass::foo"); 79 } 80 } 81 new InStaticClass().foo() 82 } 83} 84 85export function sendableFuncUseLocalModuleValue() { 86 "use sendable"; 87 new SendableLocalClass().func("SendableFuncUseLocalModuleValue"); 88 sendableLocalFunc("SendableFuncUseLocalModuleValue"); 89 new LocalClass().func("SendableFuncUseLocalModuleValue"); 90 localFunc("SendableFuncUseLocalModuleValue"); 91}