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 */ 15 16declare function print(arg:any):string; 17 18function A() { 19 this.x = 1; 20} 21 22A.prototype.foo = function() { 23 print("foo"); 24} 25 26A.prototype.bar = function() { 27 print("bar"); 28} 29 30let a = new A(); 31print(ArkTools.isTSHClass(a)); 32print(a.x); 33a.x =2; 34print(a.x); 35a.foo(); 36a.bar(); 37print(ArkTools.isTSHClass(a)); 38 39 40function B() { 41 this.x = 1; 42} 43 44function foo(b) { 45 print(b.bar); 46} 47 48let b = new B(); 49foo(b); 50 51B.prototype.bar = "bar"; 52foo(b); 53 54 55 56for(let i = 0; i<2; ++i) { 57 function C() { 58 this.x = 1; 59 } 60 let c = new C(); 61 print(c.x); 62} 63 64