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 */ 15class A_class{ 16 foo(){ 17 let localfield:string = "localstring"; 18 abstract class AbstractLocalClass{ 19 field1:int = 100; 20 } 21 class LocalClass extends AbstractLocalClass{ 22 field2:int = 200; 23 static staticfield = 300; 24 method1(){ 25 assert(this.field1 == 100); 26 assert(this.field2 == 200); 27 assert(localfield == "localstring") 28 } 29 static method2(){ 30 assert(LocalClass.staticfield == 300); 31 } 32 } 33 final class FinalLocalClass{ 34 field1:int = 100; 35 static staticfield = 300; 36 method1(){ 37 assert(this.field1 == 100); 38 assert(localfield == "localstring") 39 } 40 static method2(){ 41 assert(LocalClass.staticfield == 300); 42 } 43 } 44 45 let x:AbstractLocalClass = new LocalClass(); 46 assert(x.field1 == 100); 47 assert(x.field2 == 200); 48 assert(LocalClass.staticfield == 300) 49 x.method1(); 50 LocalClass.method2(); 51 52 let x2:FinalLocalClass = new FinalLocalClass(); 53 assert(x2.field1 == 100); 54 assert(FinalLocalClass.staticfield == 300) 55 x2.method1() 56 FinalLocalClass.method2(); 57 } 58} 59 60function main():void 61{ 62 let x3:A_class = new A_class; 63 x3.foo(); 64}