1/* 2 * Copyright (c) 2023-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 C { 17 public foo(fn: () => void): void { 18 let bar: () => void = (): void => { fn() } 19 for (let j = 0; j < 1; ++j) {} 20 } 21} 22 23function foo(arr: Object[]): void { 24 const copy: () => void = (): void => { 25 let c = arr.length 26 } 27 for (let s = 1; s < 10; s++) {} 28} 29 30function foo2(arr: Object[]): void { 31 const copy: () => void = (): void => { 32 let c = arr.length 33 } 34 let s: int 35 for (let s = 1; s < 10; s++) {} 36} 37 38 39function bar(): void { 40 let arr: short[] = [1,2,3,4] 41 let fn: (v: short) => void = (v: short): void => { 42 arr[0] = (v + 1) as short; 43 } 44 for (let arr = 0; arr < 4; ++arr) { } 45 arr = [3]; 46} 47 48 49 50function main() { 51 let arr: short[] = [1,2,3,4] 52 let fn: (v: short) => void = (v: short): void => { 53 arr[0] = (v + 1) as short; 54 } 55 for (let i = 0; i < 4; ++i) { } 56} 57