• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 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 A<T> {}
17class B<T> {}
18
19class C<T, U> {
20  public field : boolean
21
22  constructor(...p: [A<T>, B<U>]) {
23    this.field = p[0] == p[1]
24  }
25
26  constructor(a: int, ...p: [A<T>, B<U>]) {
27    this.field = p[0] == p[1]
28  }
29}
30
31function main() {
32    let a1: [A<Long>, B<Error>] = [new A<Long>, new B<Error>]
33
34    assertTrue((new C<Long, Error>(...a1)).field == false)
35    assertTrue((new C<Long, Error>(22, ...a1)).field == false)
36
37    assertTrue((new C<Long, Error>(...[new A<Long>, new B<Error>])).field == false)
38    assertTrue((new C<Long, Error>(22, ...[new A<Long>, new B<Error>])).field == false)
39
40    assertTrue((new C<Long, Error>(...[new A<Long>, new B<Error>] as [A<Long>, B<Error>])).field == false)
41    assertTrue((new C<Long, Error>(22, ...[new A<Long>, new B<Error>] as [A<Long>, B<Error>])).field == false)
42
43    assertTrue((new C<Long, Error>(new A<Long>, new B<Error>)).field == false)
44    assertTrue((new C<Long, Error>(22, new A<Long>, new B<Error>)).field == false)
45}
46