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 X {} 17class Y extends X {} 18 19abstract class A { 20 foo(x: Y): string { return "A.foo(Y)" } 21 abstract foo(x: Double): String 22 foo2(x: Y): Object { return "A.foo(Y)" } 23} 24 25class B extends A { 26 foo(x: X): string { return "B.foo(X)" } 27 foo(x: Floating): String { return "B.foo(Floating)" } 28} 29 30class C extends A { 31 foo(x: Double): String { return "C.foo(Double)" } 32 override foo2(x: Y): String { return "C.foo2(Y)" } 33} 34 35function main() { 36 assert(new B().foo(new Y()) == "B.foo(X)"); 37 assert(new B().foo(new Double()) == "B.foo(Floating)"); 38 assert(new C().foo2(new Y()) == "C.foo2(Y)") 39}