1/* 2 * Copyright (c) 2021-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 A { 17 bar(a0: int): void{ 18 let func: (a1: int) => void = (a1: int): void => { 19 console.print("bar.func"); 20 } 21 this.classf(func); 22 } 23 24 functest(func: (a1: int) => void): void { 25 func(2); 26 } 27 28 sim_print(): void { 29 console.print("sim_print"); 30 } 31 32 classf(locfunc: (a1: int) => void): void { 33 this.functest(locfunc); 34 this.functest( (a1: int): void => { console.print("lambda_func") } ); 35 let capture_param: () => void = (): void => { 36 locfunc(2); 37 } 38 let capture_this: () => void = (): void => { 39 this.sim_print(); 40 } 41 this.functest((a1: int): void => { 42 locfunc(2); 43 }); 44 locfunc(3); 45 } 46} 47 48function main(): void { 49 let testClass: A = new A(); 50 testClass.bar(2); 51} 52