1/* 2 * Copyright (c) 2023 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 */ 15declare function print(str:any):string; 16declare var ArkTools:any; 17{ 18 var hca; 19 var hcb; 20 class A { 21 value:number; 22 constructor (value:number) { 23 hca = ArkTools.getHClass(this); 24 this.value = value; 25 } 26 } 27 28 class B extends A { 29 value:number; 30 name:string; 31 constructor (value:number, name:string) { 32 super(value); 33 this.name = name; 34 hcb = ArkTools.getHClass(this); 35 } 36 } 37 38 let a = new A(123); 39 let hc1 = ArkTools.getHClass(a); 40 print(hca === hc1); 41 print(ArkTools.isTSHClass(a)); 42 43 let b = new B(456, "abc"); 44 let hc2 = ArkTools.getHClass(b); 45 print(hcb === hc2); 46 print(ArkTools.isTSHClass(b)); 47 48 print(a.value); 49 print(b.value); 50 print(b.name); 51} 52