• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024-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 B {
17    foo(a: int, op?: int): int { return a }
18}
19class A extends B {
20    override foo(a: int, op?: int): int { return a }
21}
22
23class C<T> {
24  foo(a: T, op?: T): T { return a }
25}
26class D<T> extends C<T> {
27  override foo(a: T, op?: T): T { return a }
28}
29
30function main(){
31    let a = new A();
32    let b = new B();
33    let c = new C<string>();
34    let d = new D<string>();
35
36    assertEQ(b.foo(5), a.foo(5))
37    assertNE(b.foo(6), a.foo(5))
38    assertNE(b.foo(5), a.foo(6))
39    assertEQ(c.foo("x"), d.foo("x"))
40    assertNE(c.foo("x"), d.foo("y"))
41    assertNE(c.foo("y"), d.foo("x"))
42}
43