1/** 2 * Copyright (c) 2025 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 16class SameName { 17 static /* @@ StaticFieldSameTy */a: int = 42; 18 /* @@ NonStaticFieldSameTy */a: int = 32; 19} 20 21/* @@@ NonStaticFieldSameTy Node { 22 "type": "ClassProperty", 23 "key": { 24 "type": "Identifier", 25 "name": "a", 26 "decorators": [], 27 "loc": { 28 "start": { 29 "line": 18, 30 "column": 34, 31 "program": "same_name_fields.ets" 32 }, 33 "end": { 34 "line": 18, 35 "column": 35, 36 "program": "same_name_fields.ets" 37 } 38 } 39 }, 40 "value": { 41 "type": "NumberLiteral", 42 "value": 32, 43 "loc": { 44 "start": { 45 "line": 18, 46 "column": 43, 47 "program": "same_name_fields.ets" 48 }, 49 "end": { 50 "line": 18, 51 "column": 45, 52 "program": "same_name_fields.ets" 53 } 54 } 55 }, 56 "accessibility": "public", 57 "static": false, 58 "readonly": false, 59 "declare": false, 60 "optional": false, 61 "computed": false 62} */ 63 64/* @@@ StaticFieldSameTy Node { 65 "type": "ClassProperty", 66 "key": { 67 "type": "Identifier", 68 "name": "a", 69 "decorators": [], 70 "loc": { 71 "start": { 72 "line": 17, 73 "column": 38, 74 "program": "same_name_fields.ets" 75 }, 76 "end": { 77 "line": 17, 78 "column": 39, 79 "program": "same_name_fields.ets" 80 } 81 } 82 }, 83 "value": { 84 "type": "NumberLiteral", 85 "value": 42, 86 "loc": { 87 "start": { 88 "line": 17, 89 "column": 47, 90 "program": "same_name_fields.ets" 91 }, 92 "end": { 93 "line": 17, 94 "column": 49, 95 "program": "same_name_fields.ets" 96 } 97 } 98 }, 99 "accessibility": "public", 100 "static": true, 101 "readonly": false, 102 "declare": false, 103 "optional": false, 104 "computed": false 105} */ 106 107class DiffTypes { 108 /* @@ DiffTyInt */a: int = 7; 109 static /* @@ DiffTyStr */a: string = "a"; 110} 111 112/* @@@ DiffTyInt Node { 113 "type": "ClassProperty", 114 "key": { 115 "type": "Identifier", 116 "name": "a", 117 "decorators": [], 118 "loc": { 119 "start": { 120 "line": 108, 121 "column": 23, 122 "program": "same_name_fields.ets" 123 }, 124 "end": { 125 "line": 108, 126 "column": 24, 127 "program": "same_name_fields.ets" 128 } 129 } 130 }, 131 "value": { 132 "type": "NumberLiteral", 133 "value": 7, 134 "loc": { 135 "start": { 136 "line": 108, 137 "column": 32, 138 "program": "same_name_fields.ets" 139 }, 140 "end": { 141 "line": 108, 142 "column": 33, 143 "program": "same_name_fields.ets" 144 } 145 } 146 }, 147 "accessibility": "public", 148 "static": false, 149 "readonly": false, 150 "declare": false, 151 "optional": false, 152 "computed": false 153} */ 154 155/* @@@ DiffTyStr Node { 156 "type": "ClassProperty", 157 "key": { 158 "type": "Identifier", 159 "name": "a", 160 "decorators": [], 161 "loc": { 162 "start": { 163 "line": 109, 164 "column": 30, 165 "program": "same_name_fields.ets" 166 }, 167 "end": { 168 "line": 109, 169 "column": 31, 170 "program": "same_name_fields.ets" 171 } 172 } 173 }, 174 "value": { 175 "type": "StringLiteral", 176 "value": "a", 177 "loc": { 178 "start": { 179 "line": 109, 180 "column": 42, 181 "program": "same_name_fields.ets" 182 }, 183 "end": { 184 "line": 109, 185 "column": 45, 186 "program": "same_name_fields.ets" 187 } 188 } 189 }, 190 "accessibility": "public", 191 "static": true, 192 "readonly": false, 193 "declare": false, 194 "optional": false, 195 "computed": false 196} */ 197 198function main(): void { 199 assertEQ(SameName.a, 42); 200 assertEQ((new SameName()).a, 32); 201 assertEQ(DiffTypes.a, "a"); 202 assertEQ((new DiffTypes()).a, 6); 203} 204