1/* 2 * Copyright (c) 2024-2025 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<T> { 17 constructor (p: T) { this.v = p; } 18 v : T; 19} 20 21class D<T1, T2> { 22 constructor (p: T1, q: T2) { this.v = p; this.w = q; } 23 v : T1; 24 w : T2; 25} 26 27type AliasPrimitive<T> = T; 28type AliasAlias<T> = AliasPrimitive<T>; 29 30type Alias1Class<T> = C<T>; 31type Alias2Class<T> = C<T[]>; 32type Alias3Class<T1, T2> = D<T1, T2>; 33type Alias4Class<T1, T2> = D<T2, T1>; 34type Alias5Class<T1, T2> = D<Alias1Class<T1>, AliasAlias<T2>[]> 35 36function main() { 37 let v1 : C<double> = new C<double>(1); // C<Double> 38 assertEQ(v1.v, 1) 39 40 let v2 : Alias1Class<double> = new C<double>(2); // C<Double> 41 assertEQ(v2.v, 2) 42 43 let v3 : Alias2Class<double> = new C<double[]>([3.0]); // C<double[]> 44 assertEQ(v3.v[0], 3) 45 46 let v4: Alias3Class<double, int> = new D<double, int>(4.0, 5); // D<Double, Int> 47 assertEQ(v4.v, 4.0) 48 assertEQ(v4.w, 5) 49 50 let v5: Alias4Class<double, int> = new D<int, double>(6, 7.0); // D<Int, Double> 51 assertEQ(v5.v, 6) 52 assertEQ(v5.w, 7.0) 53 54 let v6: Alias5Class<double, double> = new D<C<double>, double[]>(new C<double>(8), [9.0]); // D<C<Double>, double[]> 55 assertEQ(v6.v.v, 8) 56 assertEQ(v6.w[0], 9.0) 57} 58