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#I91CQ6 21 */ 22 23// @ts-nocheck 24declare function print(str: any): string; 25 26import lazy {Test1, foo2} from "./func" 27import {strA, strB} from "./string" 28 29class SendableClassA { 30 static staticField: string = strA; 31 constructor() { 32 "use sendable"; 33 } 34 35 testZeroLevelContext() { 36 print(SendableClassA.staticField); 37 } 38 39 testOneLevelContext() { 40 let x: number = 0; 41 (()=>{ 42 print("testOneLevelContext"); 43 print(SendableClassA.staticField + strB); 44 })(); 45 } 46 testImportFunction() { 47 let x: number = 0; 48 (()=>{ 49 print("testImportFunction"); 50 let tA = new Test1(strA); 51 print(tA.foo()); 52 })(); 53 } 54} 55 56let sObj = new SendableClassA; 57sObj.testZeroLevelContext(); 58sObj.testOneLevelContext(); 59sObj.testImportFunction(); 60 61class SendableClassB extends SendableClassA { 62 classBStr:string; 63 constructor(classBStr:string) { 64 "use sendable"; 65 super(); 66 this.classBStr = classBStr; 67 } 68 69 testImportFunction() { 70 print("testImportFunction"); 71 let tB = new Test1(strB); 72 let foo2Str = foo2(tB, "foo2") 73 print(this.classBStr + foo2Str); 74 } 75} 76 77let sObjb = new SendableClassB("ClassB: "); 78sObjb.testImportFunction() 79