• 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 low 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  /* @@ label1 */new C<Long, Error>
33  /* @@ label2 */new C<Long, Error>(new A<Long>)
34  /* @@ label3 */new C<Long, Error>(new A<Long>, new B<Error>, new B<Error>)
35}
36
37/* @@@ label1 Error TypeError: Expected 1 arguments, got 0. */
38/* @@@ label1 Error TypeError: Expected 2 arguments, got 0. */
39/* @@@ label1 Error TypeError: Expected 3 arguments, got 0. */
40/* @@@ label1 Error TypeError: No matching construct signature */
41/* @@@ label2 Error TypeError: Expected 2 arguments, got 1. */
42/* @@@ label2 Error TypeError: Expected 3 arguments, got 1. */
43/* @@@ label2 Error TypeError: No matching construct signature for rest_parameter_13.C(A<Long>) */
44/* @@? 33:37 Error TypeError: Type 'A<Long>' is not compatible with type 'int' at index 1 */
45/* @@@ label3 Error TypeError: Expected 2 arguments, got 3. */
46/* @@@ label3 Error TypeError: No matching construct signature for rest_parameter_13.C(A<Long>, B<Error>, B<Error>) */
47/* @@? 34:37 Error TypeError: Type 'A<Long>' is not compatible with type 'int' at index 1 */
48