1/*
2 * Copyright (c) 2023-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 */
15
16abstract class A {
17    str: string = "A"
18}
19
20abstract class B extends A {
21    public get_str(): string {
22        return this.str;
23    }
24
25    public get_super_str(): string {
26        return super.str;
27    }
28}
29
30class BB extends B {}
31
32abstract class C extends B {
33    str: string = "C"
34
35    public override get_str(): string {
36        return this.str;
37    }
38
39    public override get_super_str(): string {
40        return super.str;
41    }
42}
43
44class CC extends C {}
45
46function main(): void {
47  let b: B = new BB();
48  let c: C = new CC();
49
50  assert(b.str == "A")
51  assert(b.get_str() == "A")
52  assert(b.get_super_str() == "A")
53  assert(c.str == "C")
54  assert(c.get_str() == "C")
55  assert(c.get_super_str() == "A")
56
57  assert((b as B).str == "A")
58  assert((b as A).str == "A")
59  assert((b as B).get_str() == "A")
60  assert((b as B).get_super_str() == "A")
61
62  assert((c as C).str == "C")
63  assert((c as B).str == "A")
64  assert((c as A).str == "A")
65
66  assert((c as C).get_str() == "C")
67  assert((c as C).get_super_str() == "A")
68  assert((c as B).get_str() == "C")
69  assert((c as B).get_super_str() == "A")
70}
71