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
16class BiConsumer<T, U> {
17    accept(t: T, u: U) {
18        t;
19        u;
20    }
21}
22
23class SomeObject<T> {}
24class SomeType {}
25class OtherType {}
26
27class Base { 
28    foo_default<T, C=T, B=C, A=B, U=A>(): BiConsumer<T, U> { 
29        return new BiConsumer<T, U>() 
30    }
31    foo_array<T, U=T[]>(): BiConsumer<T, U> { 
32        return new BiConsumer<T, U>() 
33    }
34    foo_array_implicit<T, X=T, U=X[]>(): BiConsumer<T, U> { 
35        return new BiConsumer<T, U>() 
36    }
37    foo_union<T, F = OtherType, U= T | F>(): BiConsumer<T, U> { 
38        return new BiConsumer<T, U>() 
39    }
40    foo_object<T, U=SomeObject<T>>(): BiConsumer<T, U> { 
41        return new BiConsumer<T, U>() 
42    }
43}
44
45function main(): int {
46    new Base().foo_default<SomeType>().accept(new SomeType(), new SomeType())
47    new Base().foo_array<SomeType>().accept(new SomeType(), [new SomeType()])
48    new Base().foo_array_implicit<SomeType>().accept(new SomeType(), [new SomeType()])
49    new Base().foo_union<SomeType>().accept(new SomeType(), new SomeType())
50    new Base().foo_union<SomeType>().accept(new SomeType(), new OtherType())
51    new Base().foo_object<SomeType>().accept(new SomeType(), new SomeObject<SomeType>)
52    return 0
53}
54