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 */
15
16declare function print(str:any):string;
17declare var ArkTools:any;
18
19class A {
20    name:string;
21    value:number;
22    constructor(name:string, value:number) {
23        this.name = name;
24        this.value = value;
25    }
26}
27class B extends A {
28    constructor(name:string, value:number) {
29        super(name, value);
30    }
31}
32
33var obj = new B("AOT", 123);
34print(obj.name);
35print(obj.value);
36
37class M {
38    constructor(value) {
39        this.stageValue = value;
40    }
41}
42class BM extends M {
43    constructor(value) {
44        super(value);
45    }
46}
47
48let mdf = new M(2);
49print(mdf.stageValue);
50for (let i = 0; i < 12; i++) {
51    mdf = new BM(9);
52}
53print(mdf.stageValue);
54
55//deoptimized case:
56let args = { name: 'encoding', params: '"utf-8"' }
57let isClean = Symbol('isClean')
58let my = Symbol('my')
59class Base {
60    constructor(defaults) {
61        this.raws = defaults
62        this[isClean] = false
63        this[my] = true
64    }
65}
66
67class Son extends Base {
68    constructor(defaults) {
69        super(defaults)
70        this.type = 'atrule'
71    }
72}
73
74let b = new Base(args)
75print(ArkTools.isAOTCompiled(Base))
76print(ArkTools.isAOTDeoptimized(Base))
77
78let s = new Son(args)
79print(ArkTools.isAOTCompiled(Son))
80print(ArkTools.isAOTDeoptimized(Son))
81
82
83
84//optimized case
85class Base2 {
86    constructor(defaults = {}) {
87        this.raws = defaults
88    }
89}
90
91class Son2 extends Base2 {
92    constructor(defaults) {
93        super(defaults)
94        this.type = 'atrule'
95    }
96}
97let b2 = new Base2(args)
98print(ArkTools.isAOTCompiled(Base2))
99print(ArkTools.isAOTDeoptimized(Base2))
100
101let s2 = new Son2(args)
102print(ArkTools.isAOTCompiled(Son2))
103print(ArkTools.isAOTDeoptimized(Son2))