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 A { 17 public a:int; 18 constructor(param: int=101) { 19 this.a = param; 20 } 21 public SetA(param: int = 99) { 22 this.a = param; 23 } 24} 25 26class C extends A { 27 static fs:int=102 28 fc:int=10001; 29 c:int; 30 public setC (param:int=this.fc) : void { 31 this.c = param; 32 } 33 public getC() : int { 34 return this.c; 35 } 36 static foo(param: int=C.fs) : int { 37 return C.fs+param; 38 } 39} 40 41function main(): void { 42 let b: C = new C(); 43 assert (b.a == 101) 44 b.setC(); 45 assert(b.getC() == 10001) 46 assert(C.foo() == (C.fs*2)) 47} 48