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 17function foo1 (tuple: Readonly<[number, string, boolean]>, arr: Readonly<number[]>) { 18 let x: Readonly<[number, string]> = [1, "a"] 19 let x2: Readonly<[string, double]> 20 let y: Readonly<int[]> = [] 21 let y2: Readonly<string[]> 22} 23 24function foo2 (px: Readonly<int[]>, py: Readonly<[string, float]>) { 25 let x2 : Readonly<int[]> = px 26 let y2 : Readonly<[string, float]> = py 27} 28 29 30function foo3 (x: Readonly<int[]>, x2: int[]) { 31 x = [1, 2] 32 x = new int[10] 33 let y: int[] = [] 34 x = y 35 x = x2 36} 37 38function foo4 (x: Readonly<[int, string]>, x2: [int, string]) { 39 x = [1, "abc"] 40 let y : [int, string] = [1, "abc"] 41 x = y 42 x = x2 43} 44 45function main() : void { 46 foo1([1, "ab", true], [1, 2]) 47 48 let x2: Readonly<int[]> = [] 49 let y2: Readonly<[string, float]> = ["a", 0.1] 50 foo2(x2, y2) 51 52 let x : Readonly<int[]> = [] 53 x = [1, 2] 54 let y : Readonly<[int, string]> = [1, "abc"] 55 y = [10, "cde"] 56 foo3([1, 2], [1, 2]) 57 foo4([1, "xx"], [1, "xx"]) 58}