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 B<T> {
17    test(c: B<T>): B<T> {
18        return c;
19    }
20
21    test2(c: B<T>): B<T> {
22        return this;
23    }
24}
25
26class A<T> {
27    bar(): A<T> {
28        return this;
29    }
30
31    baz(): C<T> | null {
32        return null;
33    }
34}
35
36class C<T> {
37    then<U>(a0: U): C<U> | null {
38        return null;
39    }
40
41    public value: T;
42}
43
44function bar(p: C<Object>): void {
45    let b_Int: B<Int> = new B<Int>();
46    b_Int.test(b_Int);
47
48    let p1: C<Object> | null = p.then<Object>(new Object());
49    let p2: C<A<A<Object>>> = new C<A<A<Object>>>();
50    p1 = p2.then<Object>(new Object());
51    p1 = p2.value.bar().baz()!.then<Object>(new Object());
52    p1 = p2.value.bar().baz()!.then<Object>(new Object());
53
54    let p3: C<Double> | null = p.then<Double>(new Double());
55    let p4: C<A<A<Double>>> = new C<A<A<Double>>>();
56}
57