• 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 */
15class A_class{
16    localfield:string = "localstring";
17    foo(){
18        abstract class AbstractLocalClass{}
19        class LocalClass extends AbstractLocalClass{
20            method1():string{
21                return localfield;
22            }
23        }
24        final class FinalLocalClass{
25            method1():string{
26                return this.localfield;
27            }
28        }
29
30        class ExtendsLocalClass extends FinalLocalClass{}
31        abstract final class AbstractFinalLocalClass{}
32
33        abstract class AbstractLocalClass2{
34            method1(){}
35        }
36        let a:AbstractLocalClass2 = new AbstractLocalClass2();
37
38        abstract class AbstractLocalClass3{
39            abstract override method1()
40            abstract method2(){}
41        }
42
43        final class FinalLocalClass2 extends AbstractLocalClass3{
44            override method2(){}
45            abstract method3()
46        }
47
48
49    }
50}
51
52/* @@? 21:24 Error TypeError: Property 'localfield' of enclosing class 'A_class' is not allowed to be captured from the local class 'LocalClass'  */
53/* @@? 21:24 Error TypeError: Property 'localfield' must be accessed through 'this'  */
54/* @@? 26:29 Error TypeError: Property 'localfield' does not exist on type 'FinalLocalClass'  */
55/* @@? 30:41 Error TypeError: Cannot inherit with 'final' modifier.  */
56/* @@? 31:53 Error TypeError: Cannot use both 'final' and 'abstract' modifiers.  */
57/* @@? 36:37 Error TypeError: AbstractLocalClass2 is abstract therefore cannot be instantiated.  */
58/* @@? 39:13 Error TypeError: Invalid method modifier(s): an abstract method can't have private, override, static, final or native modifier.  */
59/* @@? 40:31 Error TypeError: Native, Abstract and Declare methods cannot have body.  */
60/* @@? 43:65 Error TypeError: FinalLocalClass2 is not abstract and does not override abstract method method3(): void in FinalLocalClass2  */
61/* @@? 45:13 Error TypeError: Non abstract class has abstract method.  */