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=SomeType, C=T, B=C, A=B, U=A>(): BiConsumer<T, U> { 29 return new BiConsumer<T, U>() 30 } 31 foo_implicit<T=SomeType, F=SomeType, U=F>(x: F): BiConsumer<T, U> { 32 return new BiConsumer<T, U>() 33 } 34 foo_array<T=SomeType, U=T[]>(): BiConsumer<T, U> { 35 return new BiConsumer<T, U>() 36 } 37 foo_array_implicit<X, T=SomeType, U=X[]>(x : X): BiConsumer<T, U> { 38 return new BiConsumer<T, U>() 39 } 40 foo_union<T=SomeType, F = OtherType, U= T | F>(): BiConsumer<T, U> { 41 return new BiConsumer<T, U>() 42 } 43 foo_object<T=SomeType, U=SomeObject<T>>(): BiConsumer<T, U> { 44 return new BiConsumer<T, U>() 45 } 46} 47 48function main(): int { 49 new Base().foo_default().accept(new SomeType(), new SomeType()) 50 new Base().foo_implicit(new OtherType()).accept(new SomeType(), new OtherType()) 51 new Base().foo_array().accept(new SomeType(), [new SomeType()]) 52 new Base().foo_array_implicit(new OtherType()).accept(new SomeType(), [new OtherType()]) 53 new Base().foo_union().accept(new SomeType(), new SomeType()) 54 new Base().foo_union().accept(new SomeType(), new OtherType()) 55 new Base().foo_object().accept(new SomeType(), new SomeObject<SomeType>) 56 return 0 57} 58