• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 */
15function main():void
16{
17    let localint:int = 200;
18
19    abstract class AbstractLocalClass{
20        field1:int = 10;
21    }
22
23    class LocalClass extends AbstractLocalClass{
24        field2:int = 20;
25        static staticfield = 30;
26        method1(){
27            assert(this.field1 == 10);
28            assert(this.field2 == 20);
29            assert(localint == 200);
30        }
31        static method2(){
32            assert(LocalClass.staticfield == 30);
33        }
34    }
35
36    final class FinalLocalClass{
37        field1:int = 10;
38        static staticfield = 30;
39        method1(){
40            assert(this.field1 == 10);
41            assert(localint == 200);
42        }
43        static method2(){
44            assert(FinalLocalClass.staticfield == 30);
45        }
46    }
47
48    let x:AbstractLocalClass = new LocalClass();
49    assert(x.field1 == 10);
50    assert(x.field2 == 20);
51    assert(LocalClass.staticfield == 30)
52    x.method1();
53    LocalClass.method2();
54
55    let x2:FinalLocalClass = new FinalLocalClass();
56    assert(x2.field1 == 10);
57    assert(FinalLocalClass.staticfield == 30)
58    x2.method1()
59    FinalLocalClass.method2();
60}