arkanalyzer 1.0.94 → 2.0.0-beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (291) hide show
  1. package/lib/Config.d.ts +7 -0
  2. package/lib/Config.d.ts.map +1 -1
  3. package/lib/Scene.d.ts +134 -170
  4. package/lib/Scene.d.ts.map +1 -1
  5. package/lib/Scene.js +412 -976
  6. package/lib/callgraph/algorithm/AbstractAnalysis.js +3 -2
  7. package/lib/callgraph/algorithm/RapidTypeAnalysis.js +1 -1
  8. package/lib/callgraph/model/CallGraph.js +1 -1
  9. package/lib/callgraph/pointerAnalysis/PTAUtils.d.ts +1 -3
  10. package/lib/callgraph/pointerAnalysis/PTAUtils.d.ts.map +1 -1
  11. package/lib/callgraph/pointerAnalysis/PTAUtils.js +17 -7
  12. package/lib/callgraph/pointerAnalysis/Pag.d.ts.map +1 -1
  13. package/lib/callgraph/pointerAnalysis/Pag.js +4 -14
  14. package/lib/callgraph/pointerAnalysis/PagBuilder.d.ts.map +1 -1
  15. package/lib/callgraph/pointerAnalysis/PagBuilder.js +2 -1
  16. package/lib/callgraph/pointerAnalysis/PointerAnalysis.d.ts.map +1 -1
  17. package/lib/callgraph/pointerAnalysis/PointerAnalysis.js +1 -2
  18. package/lib/callgraph/pointerAnalysis/plugins/WorkerPlugin.d.ts.map +1 -1
  19. package/lib/callgraph/pointerAnalysis/plugins/WorkerPlugin.js +0 -1
  20. package/lib/cli/commands/cg.d.ts +1 -0
  21. package/lib/cli/commands/cg.d.ts.map +1 -1
  22. package/lib/cli/commands/cg.js +22 -18
  23. package/lib/cli/commands/ir.d.ts +1 -0
  24. package/lib/cli/commands/ir.d.ts.map +1 -1
  25. package/lib/cli/commands/ir.js +5 -2
  26. package/lib/core/base/Constant.d.ts +5 -5
  27. package/lib/core/base/Constant.d.ts.map +1 -1
  28. package/lib/core/base/Constant.js +12 -9
  29. package/lib/core/base/Expr.d.ts +36 -20
  30. package/lib/core/base/Expr.d.ts.map +1 -1
  31. package/lib/core/base/Expr.js +206 -94
  32. package/lib/core/base/Local.d.ts +10 -20
  33. package/lib/core/base/Local.d.ts.map +1 -1
  34. package/lib/core/base/Local.js +25 -28
  35. package/lib/core/base/Position.d.ts +6 -0
  36. package/lib/core/base/Position.d.ts.map +1 -1
  37. package/lib/core/base/Position.js +37 -11
  38. package/lib/core/base/Ref.d.ts +45 -33
  39. package/lib/core/base/Ref.d.ts.map +1 -1
  40. package/lib/core/base/Ref.js +225 -51
  41. package/lib/core/base/Stmt.d.ts +19 -9
  42. package/lib/core/base/Stmt.d.ts.map +1 -1
  43. package/lib/core/base/Stmt.js +135 -52
  44. package/lib/core/base/Type.d.ts +67 -4
  45. package/lib/core/base/Type.d.ts.map +1 -1
  46. package/lib/core/base/Type.js +391 -20
  47. package/lib/core/base/TypeExpr.d.ts +6 -4
  48. package/lib/core/base/TypeExpr.d.ts.map +1 -1
  49. package/lib/core/base/TypeExpr.js +34 -10
  50. package/lib/core/base/Value.d.ts +20 -2
  51. package/lib/core/base/Value.d.ts.map +1 -1
  52. package/lib/core/base/Value.js +12 -0
  53. package/lib/core/common/ArkIRTransformer.d.ts +18 -0
  54. package/lib/core/common/ArkIRTransformer.d.ts.map +1 -1
  55. package/lib/core/common/ArkIRTransformer.js +94 -75
  56. package/lib/core/common/ArkValueTransformer.d.ts +21 -3
  57. package/lib/core/common/ArkValueTransformer.d.ts.map +1 -1
  58. package/lib/core/common/ArkValueTransformer.js +455 -265
  59. package/lib/core/common/Builtin.d.ts +48 -24
  60. package/lib/core/common/Builtin.d.ts.map +1 -1
  61. package/lib/core/common/Builtin.js +90 -52
  62. package/lib/core/common/CanonicalizerValidator.d.ts +308 -0
  63. package/lib/core/common/CanonicalizerValidator.d.ts.map +1 -0
  64. package/lib/core/common/CanonicalizerValidator.js +888 -0
  65. package/lib/core/common/Const.d.ts +3 -3
  66. package/lib/core/common/Const.d.ts.map +1 -1
  67. package/lib/core/common/Const.js +3 -3
  68. package/lib/core/common/DummyMainCreater.d.ts +2 -21
  69. package/lib/core/common/DummyMainCreater.d.ts.map +1 -1
  70. package/lib/core/common/DummyMainCreater.js +8 -105
  71. package/lib/core/common/IRInference.d.ts +55 -3
  72. package/lib/core/common/IRInference.d.ts.map +1 -1
  73. package/lib/core/common/IRInference.js +407 -126
  74. package/lib/core/common/IRUtils.d.ts +1 -0
  75. package/lib/core/common/IRUtils.d.ts.map +1 -1
  76. package/lib/core/common/IRUtils.js +44 -13
  77. package/lib/core/common/ModelUtils.d.ts +44 -20
  78. package/lib/core/common/ModelUtils.d.ts.map +1 -1
  79. package/lib/core/common/ModelUtils.js +378 -208
  80. package/lib/core/common/SdkUtils.d.ts +35 -5
  81. package/lib/core/common/SdkUtils.d.ts.map +1 -1
  82. package/lib/core/common/SdkUtils.js +181 -53
  83. package/lib/core/common/SignatureCanonicalizer.d.ts +95 -0
  84. package/lib/core/common/SignatureCanonicalizer.d.ts.map +1 -0
  85. package/lib/core/common/SignatureCanonicalizer.js +116 -0
  86. package/lib/core/common/SignatureCanonicalizerRegistry.d.ts +176 -0
  87. package/lib/core/common/SignatureCanonicalizerRegistry.d.ts.map +1 -0
  88. package/lib/core/common/SignatureCanonicalizerRegistry.js +343 -0
  89. package/lib/core/common/SignatureModelCanonicalizer.d.ts +69 -0
  90. package/lib/core/common/SignatureModelCanonicalizer.d.ts.map +1 -0
  91. package/lib/core/common/SignatureModelCanonicalizer.js +109 -0
  92. package/lib/core/common/StmtUseReplacer.d.ts +1 -0
  93. package/lib/core/common/StmtUseReplacer.d.ts.map +1 -1
  94. package/lib/core/common/StmtUseReplacer.js +9 -0
  95. package/lib/core/common/StringUtils.d.ts +12 -1
  96. package/lib/core/common/StringUtils.d.ts.map +1 -1
  97. package/lib/core/common/StringUtils.js +36 -17
  98. package/lib/core/common/TempSignatureCanonicalizer.d.ts +82 -0
  99. package/lib/core/common/TempSignatureCanonicalizer.d.ts.map +1 -0
  100. package/lib/core/common/TempSignatureCanonicalizer.js +177 -0
  101. package/lib/core/common/TypeInference.d.ts +24 -6
  102. package/lib/core/common/TypeInference.d.ts.map +1 -1
  103. package/lib/core/common/TypeInference.js +243 -117
  104. package/lib/core/common/ValueUtil.d.ts +2 -1
  105. package/lib/core/common/ValueUtil.d.ts.map +1 -1
  106. package/lib/core/common/ValueUtil.js +4 -1
  107. package/lib/core/graph/Cfg.d.ts.map +1 -1
  108. package/lib/core/graph/Cfg.js +21 -6
  109. package/lib/core/graph/builder/CfgBuilder.d.ts.map +1 -1
  110. package/lib/core/graph/builder/CfgBuilder.js +46 -33
  111. package/lib/core/graph/builder/IfBuilder.d.ts.map +1 -1
  112. package/lib/core/graph/builder/IfBuilder.js +6 -2
  113. package/lib/core/graph/builder/ViewTreeBuilder.d.ts.map +1 -1
  114. package/lib/core/graph/builder/ViewTreeBuilder.js +6 -2
  115. package/lib/core/inference/ModelInference.d.ts +24 -4
  116. package/lib/core/inference/ModelInference.d.ts.map +1 -1
  117. package/lib/core/inference/ModelInference.js +273 -79
  118. package/lib/core/inference/ValueInference.d.ts +3 -2
  119. package/lib/core/inference/ValueInference.d.ts.map +1 -1
  120. package/lib/core/inference/ValueInference.js +90 -40
  121. package/lib/core/inference/abc/AbcInference.d.ts.map +1 -1
  122. package/lib/core/inference/abc/AbcInference.js +28 -15
  123. package/lib/core/inference/arkts/ArkTsInference.d.ts +9 -3
  124. package/lib/core/inference/arkts/ArkTsInference.d.ts.map +1 -1
  125. package/lib/core/inference/arkts/ArkTsInference.js +54 -16
  126. package/lib/core/model/ArkClass.d.ts +192 -18
  127. package/lib/core/model/ArkClass.d.ts.map +1 -1
  128. package/lib/core/model/ArkClass.js +852 -122
  129. package/lib/core/model/ArkExport.d.ts.map +1 -1
  130. package/lib/core/model/ArkExport.js +1 -2
  131. package/lib/core/model/ArkField.d.ts +34 -2
  132. package/lib/core/model/ArkField.d.ts.map +1 -1
  133. package/lib/core/model/ArkField.js +89 -14
  134. package/lib/core/model/ArkFile.d.ts +72 -12
  135. package/lib/core/model/ArkFile.d.ts.map +1 -1
  136. package/lib/core/model/ArkFile.js +275 -65
  137. package/lib/core/model/ArkImport.d.ts.map +1 -1
  138. package/lib/core/model/ArkImport.js +1 -2
  139. package/lib/core/model/ArkMethod.d.ts +101 -15
  140. package/lib/core/model/ArkMethod.d.ts.map +1 -1
  141. package/lib/core/model/ArkMethod.js +252 -39
  142. package/lib/core/model/ArkModule.d.ts +1 -1
  143. package/lib/core/model/ArkModule.js +1 -1
  144. package/lib/core/model/ArkNamespace.d.ts +80 -10
  145. package/lib/core/model/ArkNamespace.d.ts.map +1 -1
  146. package/lib/core/model/ArkNamespace.js +309 -76
  147. package/lib/core/model/ArkSignature.d.ts +242 -18
  148. package/lib/core/model/ArkSignature.d.ts.map +1 -1
  149. package/lib/core/model/ArkSignature.js +725 -95
  150. package/lib/core/model/builder/ArkClassBuilder.d.ts +6 -3
  151. package/lib/core/model/builder/ArkClassBuilder.d.ts.map +1 -1
  152. package/lib/core/model/builder/ArkClassBuilder.js +116 -71
  153. package/lib/core/model/builder/ArkExportBuilder.d.ts +1 -1
  154. package/lib/core/model/builder/ArkExportBuilder.d.ts.map +1 -1
  155. package/lib/core/model/builder/ArkExportBuilder.js +1 -1
  156. package/lib/core/model/builder/ArkFieldBuilder.d.ts +0 -2
  157. package/lib/core/model/builder/ArkFieldBuilder.d.ts.map +1 -1
  158. package/lib/core/model/builder/ArkFieldBuilder.js +9 -43
  159. package/lib/core/model/builder/ArkFileBuilder.d.ts.map +1 -1
  160. package/lib/core/model/builder/ArkFileBuilder.js +32 -33
  161. package/lib/core/model/builder/ArkMethodBuilder.d.ts +10 -3
  162. package/lib/core/model/builder/ArkMethodBuilder.d.ts.map +1 -1
  163. package/lib/core/model/builder/ArkMethodBuilder.js +40 -26
  164. package/lib/core/model/builder/ArkNamespaceBuilder.d.ts +3 -2
  165. package/lib/core/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
  166. package/lib/core/model/builder/ArkNamespaceBuilder.js +45 -77
  167. package/lib/core/model/builder/ArkSignatureBuilder.d.ts +9 -0
  168. package/lib/core/model/builder/ArkSignatureBuilder.d.ts.map +1 -1
  169. package/lib/core/model/builder/ArkSignatureBuilder.js +26 -3
  170. package/lib/core/model/builder/BodyBuilder.d.ts +1 -0
  171. package/lib/core/model/builder/BodyBuilder.d.ts.map +1 -1
  172. package/lib/core/model/builder/BodyBuilder.js +37 -11
  173. package/lib/core/model/builder/builderUtils.d.ts +11 -1
  174. package/lib/core/model/builder/builderUtils.d.ts.map +1 -1
  175. package/lib/core/model/builder/builderUtils.js +124 -90
  176. package/lib/frontend/FrontendBuilder.d.ts +10 -6
  177. package/lib/frontend/FrontendBuilder.d.ts.map +1 -1
  178. package/lib/frontend/FrontendBuilder.js +19 -45
  179. package/lib/frontend/ModuleScene.d.ts +43 -0
  180. package/lib/frontend/ModuleScene.d.ts.map +1 -0
  181. package/lib/frontend/ModuleScene.js +143 -0
  182. package/lib/frontend/SceneBuildStage.d.ts +15 -0
  183. package/lib/frontend/SceneBuildStage.d.ts.map +1 -0
  184. package/lib/frontend/SceneBuildStage.js +32 -0
  185. package/lib/frontend/SceneBuilder.d.ts +153 -0
  186. package/lib/frontend/SceneBuilder.d.ts.map +1 -0
  187. package/lib/frontend/SceneBuilder.js +859 -0
  188. package/lib/frontend/arktsFrontend/ArktsFrontend.d.ts +0 -2
  189. package/lib/frontend/arktsFrontend/ArktsFrontend.d.ts.map +1 -1
  190. package/lib/frontend/arktsFrontend/ArktsFrontend.js +0 -18
  191. package/lib/frontend/arktsFrontend/FileBodyRemount.d.ts +17 -0
  192. package/lib/frontend/arktsFrontend/FileBodyRemount.d.ts.map +1 -0
  193. package/lib/frontend/arktsFrontend/FileBodyRemount.js +187 -0
  194. package/lib/frontend/common/ModuleBuilder.d.ts +4 -2
  195. package/lib/frontend/common/ModuleBuilder.d.ts.map +1 -1
  196. package/lib/frontend/common/ModuleBuilder.js +19 -9
  197. package/lib/frontend/cppFrontend/CppFrontend.d.ts +0 -6
  198. package/lib/frontend/cppFrontend/CppFrontend.d.ts.map +1 -1
  199. package/lib/frontend/cppFrontend/CppFrontend.js +0 -56
  200. package/lib/frontend/cppFrontend/base/Type.d.ts +7 -0
  201. package/lib/frontend/cppFrontend/base/Type.d.ts.map +1 -1
  202. package/lib/frontend/cppFrontend/base/Type.js +29 -0
  203. package/lib/frontend/cppFrontend/common/ArkIRTransformer.d.ts.map +1 -1
  204. package/lib/frontend/cppFrontend/common/ArkIRTransformer.js +56 -56
  205. package/lib/frontend/cppFrontend/common/ArkValueTransformer.d.ts +1 -1
  206. package/lib/frontend/cppFrontend/common/ArkValueTransformer.d.ts.map +1 -1
  207. package/lib/frontend/cppFrontend/common/ArkValueTransformer.js +124 -113
  208. package/lib/frontend/cppFrontend/common/Builtin.d.ts +29 -19
  209. package/lib/frontend/cppFrontend/common/Builtin.d.ts.map +1 -1
  210. package/lib/frontend/cppFrontend/common/Builtin.js +56 -35
  211. package/lib/frontend/cppFrontend/common/IRInference.d.ts +7 -2
  212. package/lib/frontend/cppFrontend/common/IRInference.d.ts.map +1 -1
  213. package/lib/frontend/cppFrontend/common/IRInference.js +61 -28
  214. package/lib/frontend/cppFrontend/common/IRUtils.d.ts +1 -0
  215. package/lib/frontend/cppFrontend/common/IRUtils.d.ts.map +1 -1
  216. package/lib/frontend/cppFrontend/common/IRUtils.js +22 -10
  217. package/lib/frontend/cppFrontend/common/ModelUtils.d.ts +19 -0
  218. package/lib/frontend/cppFrontend/common/ModelUtils.d.ts.map +1 -1
  219. package/lib/frontend/cppFrontend/common/ModelUtils.js +84 -3
  220. package/lib/frontend/cppFrontend/common/TypeInference.d.ts.map +1 -1
  221. package/lib/frontend/cppFrontend/common/TypeInference.js +44 -54
  222. package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.d.ts.map +1 -1
  223. package/lib/frontend/cppFrontend/graph/builder/CfgBuilder.js +2 -1
  224. package/lib/frontend/cppFrontend/inference/CxxModelInference.d.ts +1 -1
  225. package/lib/frontend/cppFrontend/inference/CxxModelInference.d.ts.map +1 -1
  226. package/lib/frontend/cppFrontend/inference/CxxValueInference.d.ts.map +1 -1
  227. package/lib/frontend/cppFrontend/inference/CxxValueInference.js +41 -5
  228. package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.d.ts.map +1 -1
  229. package/lib/frontend/cppFrontend/model/builder/ArkClassBuilder.js +18 -28
  230. package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.d.ts.map +1 -1
  231. package/lib/frontend/cppFrontend/model/builder/ArkFieldBuilder.js +2 -3
  232. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.d.ts +2 -2
  233. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.d.ts.map +1 -1
  234. package/lib/frontend/cppFrontend/model/builder/ArkFileBuilder.js +31 -24
  235. package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.d.ts.map +1 -1
  236. package/lib/frontend/cppFrontend/model/builder/ArkMethodBuilder.js +10 -16
  237. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.d.ts +0 -2
  238. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.d.ts.map +1 -1
  239. package/lib/frontend/cppFrontend/model/builder/ArkNamespaceBuilder.js +19 -37
  240. package/lib/frontend/cppFrontend/model/builder/BodyBuilder.d.ts +1 -0
  241. package/lib/frontend/cppFrontend/model/builder/BodyBuilder.d.ts.map +1 -1
  242. package/lib/frontend/cppFrontend/model/builder/BodyBuilder.js +30 -3
  243. package/lib/frontend/cppFrontend/model/builder/builderUtils.d.ts.map +1 -1
  244. package/lib/frontend/cppFrontend/model/builder/builderUtils.js +8 -4
  245. package/lib/index.d.ts +3 -0
  246. package/lib/index.d.ts.map +1 -1
  247. package/lib/index.js +10 -2
  248. package/lib/save/json/JsonSerialization.js +2 -2
  249. package/lib/save/source/SourceStmt.js +1 -1
  250. package/lib/save/source/SourceTransformer.d.ts.map +1 -1
  251. package/lib/save/source/SourceTransformer.js +0 -9
  252. package/lib/statistics/StageStatistics.d.ts +195 -0
  253. package/lib/statistics/StageStatistics.d.ts.map +1 -0
  254. package/lib/statistics/StageStatistics.js +346 -0
  255. package/lib/statistics/StageStatisticsReporter.d.ts +58 -0
  256. package/lib/statistics/StageStatisticsReporter.d.ts.map +1 -0
  257. package/lib/statistics/StageStatisticsReporter.js +255 -0
  258. package/lib/utils/Canonicalizer.d.ts +9 -2
  259. package/lib/utils/Canonicalizer.d.ts.map +1 -1
  260. package/lib/utils/Canonicalizer.js +19 -2
  261. package/lib/utils/CxxSceneUtils.d.ts +7 -0
  262. package/lib/utils/CxxSceneUtils.d.ts.map +1 -1
  263. package/lib/utils/CxxSceneUtils.js +10 -1
  264. package/lib/utils/FileUtils.d.ts +0 -1
  265. package/lib/utils/FileUtils.d.ts.map +1 -1
  266. package/lib/utils/FileUtils.js +1 -9
  267. package/lib/utils/HashUtils.d.ts +9 -0
  268. package/lib/utils/HashUtils.d.ts.map +1 -0
  269. package/lib/utils/HashUtils.js +65 -0
  270. package/lib/utils/ModuleUtils.d.ts.map +1 -1
  271. package/lib/utils/ModuleUtils.js +24 -5
  272. package/lib/utils/VisitedSegment.d.ts +23 -0
  273. package/lib/utils/VisitedSegment.d.ts.map +1 -0
  274. package/lib/utils/VisitedSegment.js +64 -0
  275. package/lib/utils/callGraphUtils.d.ts.map +1 -1
  276. package/lib/utils/callGraphUtils.js +7 -7
  277. package/lib/utils/getAllFiles.d.ts.map +1 -1
  278. package/lib/utils/getAllFiles.js +11 -8
  279. package/lib/utils/logger.d.ts +4 -0
  280. package/lib/utils/logger.d.ts.map +1 -1
  281. package/lib/utils/logger.js +16 -0
  282. package/lib/utils/parseArkSourceFile.d.ts +33 -0
  283. package/lib/utils/parseArkSourceFile.d.ts.map +1 -0
  284. package/lib/utils/parseArkSourceFile.js +131 -0
  285. package/package.json +1 -1
  286. package/lib/utils/DependenciesSort.d.ts +0 -3
  287. package/lib/utils/DependenciesSort.d.ts.map +0 -1
  288. package/lib/utils/DependenciesSort.js +0 -72
  289. package/lib/utils/crypto_utils.d.ts +0 -6
  290. package/lib/utils/crypto_utils.d.ts.map +0 -1
  291. package/lib/utils/crypto_utils.js +0 -57
@@ -39,6 +39,7 @@ exports.IRInference = void 0;
39
39
  * limitations under the License.
40
40
  */
41
41
  const ArkMethod_1 = require("../model/ArkMethod");
42
+ const ArkSignatureBuilder_1 = require("../model/builder/ArkSignatureBuilder");
42
43
  const Type_1 = require("../base/Type");
43
44
  const Local_1 = require("../base/Local");
44
45
  const TypeInference_1 = require("./TypeInference");
@@ -58,7 +59,10 @@ const ValueUtil_1 = require("./ValueUtil");
58
59
  const TypeExpr_1 = require("../base/TypeExpr");
59
60
  const ArkBaseModel_1 = require("../model/ArkBaseModel");
60
61
  const SdkUtils_1 = require("./SdkUtils");
62
+ const SignatureCanonicalizerRegistry_1 = require("./SignatureCanonicalizerRegistry");
61
63
  const logger = logger_1.default.getLogger(logger_1.LOG_MODULE_TYPE.ARKANALYZER, 'IRInference');
64
+ const IS_GENERIC_OR_ANY = (t) => t instanceof Type_1.GenericType || t instanceof Type_1.AnyType;
65
+ const IS_GENERIC = (t) => t instanceof Type_1.GenericType;
62
66
  class IRInference {
63
67
  static inferExportInfos(file) {
64
68
  file.getExportInfos().forEach(exportInfo => {
@@ -107,14 +111,13 @@ class IRInference {
107
111
  this.inferExportInfos(file);
108
112
  }
109
113
  static needInfer(fileSignature) {
110
- if (fileSignature === Builtin_1.Builtin.BUILT_IN_CLASSES_FILE_SIGNATURE) {
111
- return true;
112
- }
114
+ // Builtin stub signatures carry FileSignature.DEFAULT (fileName '%unk') and are
115
+ // covered by the UNKNOWN_FILE_NAME check below.
113
116
  return fileSignature.getFileName() === Const_1.UNKNOWN_FILE_NAME;
114
117
  }
115
118
  static inferStaticInvokeExpr(expr, arkMethod) {
116
- const fileSignature = expr.getMethodSignature().getDeclaringClassSignature().getDeclaringFileSignature();
117
- if (fileSignature !== ArkSignature_1.FileSignature.DEFAULT && fileSignature !== Builtin_1.Builtin.BUILT_IN_CLASSES_FILE_SIGNATURE) {
119
+ const fileSigID = expr.getMethodSignature().getDeclaringClassSignature().getDeclaringFileSigID();
120
+ if (fileSigID !== 0) {
118
121
  return expr;
119
122
  }
120
123
  const arkClass = arkMethod.getDeclaringArkClass();
@@ -134,7 +137,7 @@ class IRInference {
134
137
  else if (methodName === TSConst_1.SUPER_NAME) {
135
138
  const superClass = arkClass.getSuperClass();
136
139
  if (superClass !== null) {
137
- const newMethodSignature = new ArkSignature_1.MethodSignature(superClass.getSignature(), expr.getMethodSignature().getMethodSubSignature());
140
+ const newMethodSignature = new ArkSignature_1.MethodSignature(superClass.getClassSigID(), expr.getMethodSignature().getMethodSubSignature());
138
141
  expr.setMethodSignature(newMethodSignature);
139
142
  }
140
143
  return expr;
@@ -154,9 +157,10 @@ class IRInference {
154
157
  return this.inferStaticInvokeExprByMethodName(methodName, arkMethod, expr);
155
158
  }
156
159
  static inferStaticInvokeExprByMethodName(methodName, arkMethod, expr) {
157
- var _a, _b, _c, _d;
160
+ var _a, _b, _c, _d, _e;
161
+ const registry = SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance();
158
162
  const arkClass = arkMethod.getDeclaringArkClass();
159
- const arkExport = (_d = (_c = (_b = (_a = ModelUtils_1.ModelUtils.getStaticMethodWithName(methodName, arkClass)) !== null && _a !== void 0 ? _a : arkMethod.getFunctionLocal(methodName)) !== null && _b !== void 0 ? _b : ModelUtils_1.ModelUtils.findDeclaredLocal(new Local_1.Local(methodName), arkMethod)) !== null && _c !== void 0 ? _c : ModelUtils_1.ModelUtils.getArkExportInImportInfoWithName(methodName, arkClass.getDeclaringArkFile())) !== null && _d !== void 0 ? _d : arkClass.getDeclaringArkFile().getScene().getSdkGlobal(methodName);
163
+ const arkExport = (_e = (_d = (_c = (_b = (_a = ModelUtils_1.ModelUtils.getStaticMethodWithName(methodName, arkClass)) !== null && _a !== void 0 ? _a : IRInference.getNestedMethodInScopeChain(methodName, arkMethod)) !== null && _b !== void 0 ? _b : arkMethod.getFunctionLocal(methodName)) !== null && _c !== void 0 ? _c : ModelUtils_1.ModelUtils.findDeclaredLocal(new Local_1.Local(methodName), arkMethod)) !== null && _d !== void 0 ? _d : ModelUtils_1.ModelUtils.getArkExportInImportInfoWithName(methodName, arkClass.getDeclaringArkFile())) !== null && _e !== void 0 ? _e : SdkUtils_1.SdkUtils.getSdkGlobal(methodName);
160
164
  let method;
161
165
  let signature;
162
166
  if (arkExport instanceof ArkMethod_1.ArkMethod) {
@@ -172,7 +176,7 @@ class IRInference {
172
176
  }
173
177
  const type = TypeInference_1.TypeInference.replaceAliasType(arkExportType);
174
178
  if (type instanceof Type_1.ClassType) {
175
- const cls = arkClass.getDeclaringArkFile().getScene().getClass(type.getClassSignature());
179
+ const cls = registry.getClassBySig(type.getClassSignature());
176
180
  method = cls === null || cls === void 0 ? void 0 : cls.getMethodWithName(Const_1.CALL_SIGNATURE_NAME);
177
181
  }
178
182
  else if (type instanceof Type_1.FunctionType) {
@@ -194,6 +198,18 @@ class IRInference {
194
198
  }
195
199
  return expr;
196
200
  }
201
+ static getNestedMethodInScopeChain(methodName, arkMethod) {
202
+ let scope = arkMethod;
203
+ while (scope !== undefined && scope !== null) {
204
+ const composedName = Const_1.NAME_PREFIX + methodName + Const_1.NAME_DELIMITER + scope.getName();
205
+ const nested = scope.getDeclaringArkClass().getMethodWithName(composedName);
206
+ if (nested !== null) {
207
+ return nested;
208
+ }
209
+ scope = scope.getOuterMethod();
210
+ }
211
+ return null;
212
+ }
197
213
  static inferInstanceInvokeExpr(expr, arkMethod) {
198
214
  var _a, _b;
199
215
  const arkClass = arkMethod.getDeclaringArkClass();
@@ -230,27 +246,82 @@ class IRInference {
230
246
  this.inferBase(ref, arkMethod);
231
247
  const baseType = TypeInference_1.TypeInference.replaceAliasType(ref.getBase().getType());
232
248
  if (baseType instanceof Type_1.ArrayType && ref.getFieldName() !== 'length') {
249
+ // 本 ref 即将被 ArkArrayRef 替换——temp 行随之 retire(数组访问无字段归宿,纯 retire;dynamic ref 独占行无共享者)。
250
+ ref.retireTemp();
233
251
  return new Ref_1.ArkArrayRef(ref.getBase(), ValueUtil_1.ValueUtil.createConst(ref.getFieldName()));
234
252
  }
235
- let newFieldSignature = this.generateNewFieldSignature(ref, arkMethod.getDeclaringArkClass(), baseType);
236
- if (newFieldSignature) {
237
- if (newFieldSignature.isStatic()) {
238
- return new Ref_1.ArkStaticFieldRef(newFieldSignature);
253
+ // 判别联合消费——定义点(终点确定)走 graduateToFormal 快路径,新构造值(终点不确定)走 updateFieldSignature 决策表;static 为新建持有者
254
+ // 保留构造(formal 分支持 canonical,params 分支构造实例)。
255
+ const res = this.generateNewFieldSignature(ref, arkMethod.getDeclaringArkClass(), baseType);
256
+ return this.applyFieldResolution(ref, res);
257
+ }
258
+ /**
259
+ * @internal 终态执行——formal 分支(graduateToFormal 快路径 / static 形态替换)与
260
+ * params 分支(static probe 转换 / 就地演进)的统一收敛。static params 转换前
261
+ * probe 字段空间:miss 时 params 携带值空间成员(ns 导出的 class/enum、字段式
262
+ * static 方法引用),无 formal 归宿——直接转换会走 clear+miss error 路由并
263
+ * 多占一个 slot;miss 落入 updateFieldSignature(就地演进,上下文保留)。
264
+ */
265
+ static applyFieldResolution(ref, res) {
266
+ var _a;
267
+ if (res === null) {
268
+ return ref;
269
+ }
270
+ if (res.kind === 'formal') {
271
+ const formalId = (_a = res.formalId) !== null && _a !== void 0 ? _a : 0;
272
+ if (formalId <= 0) {
273
+ return ref;
274
+ }
275
+ if (res.staticFlag) {
276
+ ref.retireTempTo(formalId);
277
+ const canonical = SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance().fieldSigCanonicalizer.get(formalId);
278
+ return new Ref_1.ArkStaticFieldRef(canonical);
239
279
  }
240
- ref.setFieldSignature(newFieldSignature);
280
+ ref.graduateToFormal(formalId);
281
+ return ref;
241
282
  }
283
+ if (res.staticFlag) {
284
+ return IRInference.applyStaticParamsResolution(ref, res);
285
+ }
286
+ ref.updateFieldSignature(res.fieldName, res.declaringOrID, res.type, res.staticFlag, res.namespaceDeclared);
242
287
  return ref;
243
288
  }
289
+ /** params+static 分支的统一收敛(applyFieldResolution 与 updateRefSignature 共用)。 */
290
+ static applyStaticParamsResolution(ref, resolution) {
291
+ let staticSig;
292
+ if (typeof resolution.declaringOrID === 'number') {
293
+ staticSig = resolution.namespaceDeclared
294
+ ? new ArkSignature_1.FieldSignature(resolution.fieldName, resolution.declaringOrID, resolution.type, resolution.staticFlag, true)
295
+ : new ArkSignature_1.FieldSignature(resolution.fieldName, resolution.declaringOrID, resolution.type, resolution.staticFlag);
296
+ }
297
+ else {
298
+ staticSig = new ArkSignature_1.FieldSignature(resolution.fieldName, resolution.declaringOrID, resolution.type, resolution.staticFlag);
299
+ }
300
+ const registry = SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance();
301
+ const existingId = registry.fieldSigCanonicalizer.getExistingId(staticSig);
302
+ if (existingId !== -1) {
303
+ // 替换埋葬:static params 形态(新 ref 自走首路径,旧 ref 纯 retire)。
304
+ ref.retireTemp();
305
+ return new Ref_1.ArkStaticFieldRef(registry.fieldSigCanonicalizer.get(existingId));
306
+ }
307
+ // formal miss:unclear stub 经 route 干净注册 temp,再就地演进(clear declaring/type 入 temp 行,不入 formal),形态与 formal 命中路径统一。
308
+ const staticRef = new Ref_1.ArkStaticFieldRef(ArkSignatureBuilder_1.ArkSignatureBuilder.buildFieldSignatureFromFieldName(resolution.fieldName, true));
309
+ staticRef.updateFieldSignature(resolution.fieldName, resolution.declaringOrID, resolution.type, resolution.staticFlag, resolution.namespaceDeclared);
310
+ ref.retireTemp();
311
+ return staticRef;
312
+ }
244
313
  static inferBase(instance, arkMethod) {
245
314
  const base = instance.getBase();
246
315
  if (base.getName() === TSConst_1.THIS_NAME) {
247
- const name = instance instanceof Ref_1.ArkInstanceFieldRef ? instance.getFieldName() :
248
- instance.getMethodSignature().getMethodSubSignature().getMethodName();
316
+ const name = instance instanceof Ref_1.ArkInstanceFieldRef ? instance.getFieldName() : instance.getMethodSignature().getMethodSubSignature().getMethodName();
249
317
  if (name.includes('.')) {
250
318
  return;
251
319
  }
252
320
  const declaringArkClass = arkMethod.getDeclaringArkClass();
253
- if (declaringArkClass.isAnonymousClass()) {
321
+ // this-semantic guard (same as ArkTSLocalInference.infer): only the AC's
322
+ // %instInit rebinds this to the enclosing (host) this; the AC's own methods
323
+ // (constructor, named method properties) keep the build-time this — ClassType(AC).
324
+ if (declaringArkClass.isAnonymousClass() && arkMethod.getName() === Const_1.INSTANCE_INIT_METHOD_NAME) {
254
325
  let newBase = this.inferThisLocal(arkMethod);
255
326
  if (newBase) {
256
327
  instance.setBase(newBase);
@@ -292,7 +363,7 @@ class IRInference {
292
363
  static inferArgs(expr, arkMethod) {
293
364
  const scene = arkMethod.getDeclaringArkFile().getScene();
294
365
  const parameters = expr.getMethodSignature().getMethodSubSignature().getParameters();
295
- let realTypes = [];
366
+ let realTypes;
296
367
  const len = expr.getArgs().length;
297
368
  for (let index = 0; index < len; index++) {
298
369
  const arg = expr.getArg(index);
@@ -301,48 +372,61 @@ class IRInference {
301
372
  }
302
373
  const argType = arg.getType();
303
374
  const paramType = parameters[index].getType();
304
- this.inferArg(expr, argType, paramType, scene, realTypes);
375
+ realTypes = this.inferArg(expr, argType, paramType, scene, realTypes);
305
376
  }
306
- if (realTypes.length > 0 && !expr.getRealGenericTypes()) {
377
+ if (realTypes !== undefined && realTypes.length > 0 && !expr.getRealGenericTypes()) {
307
378
  expr.setRealGenericTypes(realTypes);
308
379
  }
309
380
  }
310
381
  static inferArg(expr, argType, paramType, scene, realTypes) {
311
382
  if (paramType instanceof Type_1.UnionType) {
312
- paramType.getTypes().forEach(t => this.inferArg(expr, argType, t, scene, realTypes));
383
+ const unionTypes = paramType.getTypes();
384
+ for (let i = 0; i < unionTypes.length; i++) {
385
+ realTypes = this.inferArg(expr, argType, unionTypes[i], scene, realTypes);
386
+ }
313
387
  }
314
388
  else if (paramType instanceof Type_1.AliasType) {
315
- this.inferArg(expr, argType, paramType.getOriginalType(), scene, realTypes);
389
+ realTypes = this.inferArg(expr, argType, paramType.getOriginalType(), scene, realTypes);
316
390
  }
317
391
  else if (paramType instanceof Type_1.ArrayType && argType instanceof Type_1.ArrayType) {
318
- this.inferArg(expr, argType.getBaseType(), paramType.getBaseType(), scene, realTypes);
392
+ realTypes = this.inferArg(expr, argType.getBaseType(), paramType.getBaseType(), scene, realTypes);
319
393
  }
320
394
  else if (expr instanceof Expr_1.ArkInstanceInvokeExpr && expr.getBase().getType() instanceof Type_1.ArrayType) {
321
395
  if (paramType instanceof Type_1.ArrayType && paramType.getBaseType() instanceof Type_1.GenericType) {
322
- this.inferArg(expr, argType, expr.getBase().getType().getBaseType(), scene, realTypes);
396
+ realTypes = this.inferArg(expr, argType, expr.getBase().getType().getBaseType(), scene, realTypes);
323
397
  }
324
398
  }
325
399
  if (paramType instanceof Type_1.ClassType && scene.getProjectSdkMap().has(paramType.getClassSignature().getDeclaringFileSignature().getProjectName())) {
326
400
  this.inferArgTypeWithSdk(paramType, scene, argType);
327
401
  }
328
402
  else if (paramType instanceof Type_1.GenericType) {
403
+ if (realTypes === undefined) {
404
+ realTypes = [];
405
+ }
329
406
  if (!realTypes[paramType.getIndex()]) {
330
407
  realTypes[paramType.getIndex()] = argType;
331
408
  }
332
409
  }
333
410
  else if (paramType instanceof Type_1.AnyType) {
411
+ if (realTypes === undefined) {
412
+ realTypes = [];
413
+ }
334
414
  realTypes.push(argType);
335
415
  }
336
416
  else if (paramType instanceof Type_1.FunctionType && argType instanceof Type_1.FunctionType) {
337
417
  TypeInference_1.TypeInference.inferFunctionType(argType, paramType.getMethodSignature().getMethodSubSignature(), expr.getRealGenericTypes());
338
418
  }
419
+ return realTypes;
339
420
  }
340
421
  static inferRightWithSdkType(leftType, rightType, ackClass) {
341
422
  if (leftType instanceof Type_1.AliasType) {
342
423
  this.inferRightWithSdkType(TypeInference_1.TypeInference.replaceAliasType(leftType), rightType, ackClass);
343
424
  }
344
425
  else if (leftType instanceof Type_1.UnionType) {
345
- leftType.getTypes().forEach(t => this.inferRightWithSdkType(t, rightType, ackClass));
426
+ const unionTypes = leftType.getTypes();
427
+ for (let i = 0; i < unionTypes.length; i++) {
428
+ this.inferRightWithSdkType(unionTypes[i], rightType, ackClass);
429
+ }
346
430
  }
347
431
  else if (leftType instanceof Type_1.ClassType) {
348
432
  IRInference.inferArgTypeWithSdk(leftType, ackClass.getDeclaringArkFile().getScene(), rightType);
@@ -398,7 +482,8 @@ class IRInference {
398
482
  else if (baseType instanceof Type_1.AnnotationNamespaceType) {
399
483
  const namespace = scene.getNamespace(baseType.getNamespaceSignature());
400
484
  if (namespace) {
401
- const foundMethod = ModelUtils_1.ModelUtils.findPropertyInNamespace(methodName, namespace);
485
+ // 多实体探测:跨文件同名 ns(Intl 系)的后续文件实体持有该文件声明的成员
486
+ const foundMethod = ModelUtils_1.ModelUtils.findPropertyInNamespaces(methodName, namespace);
402
487
  if (foundMethod instanceof ArkMethod_1.ArkMethod) {
403
488
  let signature = foundMethod.matchMethodSignature(expr.getArgs());
404
489
  TypeInference_1.TypeInference.inferSignatureReturnType(signature, foundMethod);
@@ -416,7 +501,7 @@ class IRInference {
416
501
  return null;
417
502
  }
418
503
  static inferInvokeExprWithArray(methodName, expr, baseType, scene) {
419
- const arrayInterface = scene.getSdkGlobal(Builtin_1.Builtin.ARRAY);
504
+ const arrayInterface = SdkUtils_1.SdkUtils.getSdkGlobal(Builtin_1.Builtin.ARRAY);
420
505
  if (arrayInterface instanceof ArkClass_1.ArkClass) {
421
506
  return this.inferInvokeExpr(expr, new Type_1.ClassType(arrayInterface.getSignature(), [baseType.getBaseType()]), methodName, scene);
422
507
  }
@@ -432,7 +517,7 @@ class IRInference {
432
517
  expr.setMethodSignature(baseType.getMethodSignature());
433
518
  return expr;
434
519
  }
435
- const funcInterface = scene.getSdkGlobal(TSConst_1.FUNCTION);
520
+ const funcInterface = SdkUtils_1.SdkUtils.getSdkGlobal(TSConst_1.FUNCTION);
436
521
  if (funcInterface instanceof ArkClass_1.ArkClass) {
437
522
  const method = ModelUtils_1.ModelUtils.findPropertyInClass(methodName, funcInterface);
438
523
  if (method instanceof ArkMethod_1.ArkMethod) {
@@ -444,47 +529,118 @@ class IRInference {
444
529
  return null;
445
530
  }
446
531
  static inferInvokeExprWithDeclaredClass(expr, baseType, methodName, scene) {
447
- var _a, _b, _c, _d, _e;
532
+ var _a, _b;
448
533
  const result = this.inferSpecialMethod(expr, baseType, methodName);
449
534
  if (result) {
450
535
  return result;
451
536
  }
452
- let declaredClass = (_a = scene.getClass(baseType.getClassSignature())) !== null && _a !== void 0 ? _a : scene.getSdkGlobal(baseType.getClassSignature().getClassName());
453
- if (!(declaredClass instanceof ArkClass_1.ArkClass)) {
454
- return null;
537
+ // 候选 declaredClass 序:签名归属实体优先(scene.getClass 值直查),再补该名字的全部全局成员提供者。
538
+ const declaredClasses = new Set();
539
+ const bySig = SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance().getClassById(baseType.getClassSigID());
540
+ if (bySig instanceof ArkClass_1.ArkClass) {
541
+ declaredClasses.add(bySig);
455
542
  }
456
- let method;
457
- if (methodName === TSConst_1.CONSTRUCTOR_NAME) {
458
- method = (_c = (_b = declaredClass === null || declaredClass === void 0 ? void 0 : declaredClass.getMethodWithName(Const_1.CONSTRUCT_SIGNATURE_NAME)) !== null && _b !== void 0 ? _b : declaredClass.getMethodWithName(Const_1.CALL_SIGNATURE_NAME)) !== null && _c !== void 0 ? _c : declaredClass === null || declaredClass === void 0 ? void 0 : declaredClass.getMethodWithName(TSConst_1.CONSTRUCTOR_NAME);
459
- if (!method) {
460
- const subSignature = new ArkSignature_1.MethodSubSignature(methodName, [], new Type_1.ClassType(baseType.getClassSignature()));
461
- expr.setMethodSignature(new ArkSignature_1.MethodSignature(baseType.getClassSignature(), subSignature));
462
- return expr;
543
+ for (const c of SdkUtils_1.SdkUtils.getSdkGlobalMemberClasses(baseType.getClassSignature().getClassName())) {
544
+ declaredClasses.add(c);
545
+ }
546
+ // ns 兄弟类候选:跨文件同名 namespace(Intl 系)中后续文件的同名类持有该文件
547
+ // 声明的成员(等价旧 copyNamespace 互拷可见性;登记序 = DFS 文件序)。
548
+ if (bySig instanceof ArkClass_1.ArkClass) {
549
+ for (const sibling of SdkUtils_1.SdkUtils.getNamespacedSiblingClasses(bySig)) {
550
+ declaredClasses.add(sibling);
463
551
  }
464
552
  }
465
- else {
553
+ if (methodName === TSConst_1.CONSTRUCTOR_NAME) {
554
+ return this.invokeConstructorOnClasses(expr, declaredClasses, baseType, methodName);
555
+ }
556
+ // 成员聚合:跨实体收集同名 method/field 候选(方法重载分散在各实体的场景,
557
+ // 如 ObjectConstructor.keys 的 es5/es2015.core 重载)。方法候选按"实参精确
558
+ // 匹配"优先——对齐旧胖类 matchMethodSignature 的 find(isMatched) ?? [0] 语义。
559
+ const methodCandidates = [];
560
+ const fieldCandidates = [];
561
+ for (const declaredClass of declaredClasses) {
466
562
  const member = ModelUtils_1.ModelUtils.findPropertyInClass(methodName, declaredClass);
467
- method = member instanceof ArkClass_1.ArkClass ? (_d = member.getMethodWithName(Const_1.CALL_SIGNATURE_NAME)) !== null && _d !== void 0 ? _d : member.getMethodWithName(TSConst_1.CONSTRUCTOR_NAME) : member;
563
+ if (member instanceof ArkClass_1.ArkClass) {
564
+ const m = (_a = member.getMethodWithName(Const_1.CALL_SIGNATURE_NAME)) !== null && _a !== void 0 ? _a : member.getMethodWithName(TSConst_1.CONSTRUCTOR_NAME);
565
+ if (m) {
566
+ methodCandidates.push({ method: m, declaredClass });
567
+ }
568
+ }
569
+ else if (member instanceof ArkMethod_1.ArkMethod) {
570
+ methodCandidates.push({ method: member, declaredClass });
571
+ }
572
+ else if (member instanceof ArkField_1.ArkField || member instanceof Local_1.Local) {
573
+ fieldCandidates.push({ member, declaredClass });
574
+ }
468
575
  }
469
- if (method instanceof ArkMethod_1.ArkMethod) {
470
- const methodSignature = method.matchMethodSignature(expr.getArgs());
471
- TypeInference_1.TypeInference.inferSignatureReturnType(methodSignature, method);
472
- expr.setMethodSignature(this.replaceMethodSignature(expr.getMethodSignature(), methodSignature));
473
- expr.setRealGenericTypes(IRInference.getRealTypes(expr, declaredClass, baseType, method));
474
- if (expr instanceof Expr_1.ArkInstanceInvokeExpr && (method.isStatic() || method.getDeclaringArkClass().isDefaultArkClass())) {
475
- return new Expr_1.ArkStaticInvokeExpr(methodSignature, expr.getArgs(), expr.getRealGenericTypes());
576
+ for (const c of methodCandidates) {
577
+ if (this.methodMatchesArgs(c.method, expr.getArgs(), scene)) {
578
+ return this.invokeMatchedMethod(expr, c.method, c.declaredClass, baseType);
476
579
  }
477
- return expr;
478
580
  }
479
- else if (method instanceof ArkField_1.ArkField || method instanceof Local_1.Local) {
480
- expr.setRealGenericTypes(IRInference.getRealTypes(expr, declaredClass, baseType));
481
- return (_e = this.changePtrInvokeExpr(method, scene, expr)) !== null && _e !== void 0 ? _e : expr;
581
+ if (methodCandidates.length > 0) {
582
+ const c = methodCandidates[0];
583
+ return this.invokeMatchedMethod(expr, c.method, c.declaredClass, baseType);
584
+ }
585
+ for (const f of fieldCandidates) {
586
+ expr.setRealGenericTypes(IRInference.getRealTypes(expr, f.declaredClass, baseType));
587
+ return (_b = this.changePtrInvokeExpr(f.member, scene, expr)) !== null && _b !== void 0 ? _b : expr;
482
588
  }
483
589
  return null;
484
590
  }
591
+ /** Whether any declaration of the method matches the given args precisely (arg-count window + type match). */
592
+ static methodMatchesArgs(method, args, scene) {
593
+ var _a;
594
+ return ((_a = method.getDeclareSignatures()) !== null && _a !== void 0 ? _a : []).some((f) => {
595
+ const parameters = f.getMethodSubSignature().getParameters();
596
+ const max = parameters.length;
597
+ let min = 0;
598
+ while (min < max && !parameters[min].isOptional()) {
599
+ min++;
600
+ }
601
+ return args.length >= min && args.length <= max && ModelUtils_1.ModelUtils.isMatched(parameters, args, scene);
602
+ });
603
+ }
604
+ /** Bind the matched method onto the invoke expr (signature + generics + static conversion). */
605
+ static invokeMatchedMethod(expr, method, declaredClass, baseType) {
606
+ const methodSignature = method.matchMethodSignature(expr.getArgs());
607
+ TypeInference_1.TypeInference.inferSignatureReturnType(methodSignature, method);
608
+ expr.setMethodSignature(this.replaceMethodSignature(expr.getMethodSignature(), methodSignature));
609
+ expr.setRealGenericTypes(IRInference.getRealTypes(expr, declaredClass, baseType, method));
610
+ if (expr instanceof Expr_1.ArkInstanceInvokeExpr && (method.isStatic() || method.getDeclaringArkClass().isDefaultArkClass())) {
611
+ return new Expr_1.ArkStaticInvokeExpr(methodSignature, expr.getArgs(), expr.getRealGenericTypes());
612
+ }
613
+ return expr;
614
+ }
615
+ /**
616
+ * Constructor-call handling across candidate classes: the first candidate owning a
617
+ * real construct-signature / call / constructor method wins; when none does, the
618
+ * legacy stub signature (over the base type) is kept.
619
+ */
620
+ static invokeConstructorOnClasses(expr, declaredClasses, baseType, methodName) {
621
+ var _a, _b;
622
+ for (const declaredClass of declaredClasses) {
623
+ const method = (_b = (_a = declaredClass.getMethodWithName(Const_1.CONSTRUCT_SIGNATURE_NAME)) !== null && _a !== void 0 ? _a : declaredClass.getMethodWithName(Const_1.CALL_SIGNATURE_NAME)) !== null && _b !== void 0 ? _b : declaredClass.getMethodWithName(TSConst_1.CONSTRUCTOR_NAME);
624
+ if (method) {
625
+ return this.invokeMatchedMethod(expr, method, declaredClass, baseType);
626
+ }
627
+ }
628
+ // No-constructor fallback (built-in lib classes behind the var-side XxxConstructor
629
+ // pattern, declare-only classes, C++ structs with an implicit default constructor, ...):
630
+ // swap in the resolved-sh signature unconditionally — the declaring side is the
631
+ // resolved baseType's class signature, so the MethodSignature object overload routes
632
+ // the declaring class through the formal hit path (no clear+miss error route), and
633
+ // no model registration happens here. Guarding this with a formal probe would strand
634
+ // the expr on its build-time %unk stub whenever the constructor has no declaration
635
+ // (C++ includeInScope MyStruct regression).
636
+ const subSignature = new ArkSignature_1.MethodSubSignature(methodName, [], new Type_1.ClassType(baseType.getClassSignature()));
637
+ expr.setMethodSignature(new ArkSignature_1.MethodSignature(baseType.getClassSignature(), subSignature));
638
+ return expr;
639
+ }
485
640
  static inferSpecialMethod(expr, baseType, methodName) {
486
- if (methodName === Builtin_1.Builtin.ITERATOR_NEXT &&
487
- baseType.getClassSignature().getDeclaringFileSignature().getProjectName() === Builtin_1.Builtin.DUMMY_PROJECT_NAME) {
641
+ // Fires only on the UNRESOLVED iterator stub (old: virtual 'ES2015' project check).
642
+ // Resolved SDK IterableIterator types take the normal declared-class path below.
643
+ if (methodName === Builtin_1.Builtin.ITERATOR_NEXT && baseType.getClassSigID() === -1 && baseType.getClassSignature().getClassName() === Builtin_1.Builtin.ITERATOR) {
488
644
  expr.getMethodSignature().getMethodSubSignature().setReturnType(Builtin_1.Builtin.ITERATOR_RESULT_CLASS_TYPE);
489
645
  expr.setRealGenericTypes(baseType.getRealGenericTypes());
490
646
  return expr;
@@ -494,7 +650,7 @@ class IRInference {
494
650
  static changePtrInvokeExpr(method, scene, expr) {
495
651
  var _a;
496
652
  let type = method.getType();
497
- if (expr.getRealGenericTypes() && TypeInference_1.TypeInference.checkType(type, t => t instanceof Type_1.GenericType || t instanceof Type_1.AnyType)) {
653
+ if (expr.getRealGenericTypes() && TypeInference_1.TypeInference.checkType(type, IS_GENERIC_OR_ANY)) {
498
654
  type = TypeInference_1.TypeInference.replaceTypeWithReal(type, expr.getRealGenericTypes());
499
655
  }
500
656
  if (type instanceof Type_1.UnionType) {
@@ -518,8 +674,9 @@ class IRInference {
518
674
  }
519
675
  }
520
676
  if (methodSignature) {
521
- const ptr = method instanceof Local_1.Local ? method :
522
- expr instanceof Expr_1.ArkInstanceInvokeExpr
677
+ const ptr = method instanceof Local_1.Local
678
+ ? method
679
+ : expr instanceof Expr_1.ArkInstanceInvokeExpr
523
680
  ? new Ref_1.ArkInstanceFieldRef(expr.getBase(), method.getSignature())
524
681
  : new Ref_1.ArkStaticFieldRef(method.getSignature());
525
682
  return new Expr_1.ArkPtrInvokeExpr(methodSignature, ptr, expr.getArgs(), expr.getRealGenericTypes());
@@ -531,10 +688,12 @@ class IRInference {
531
688
  let realTypes;
532
689
  const tmp = [];
533
690
  if (method === null || method === void 0 ? void 0 : method.getGenericTypes()) {
534
- expr.getMethodSignature().getMethodSubSignature().getParameters()
691
+ expr.getMethodSignature()
692
+ .getMethodSubSignature()
693
+ .getParameters()
535
694
  .filter(p => !p.getName().startsWith(Const_1.LEXICAL_ENV_NAME_PREFIX))
536
695
  .forEach((p, i) => {
537
- if (TypeInference_1.TypeInference.checkType(p.getType(), t => t instanceof Type_1.GenericType)) {
696
+ if (TypeInference_1.TypeInference.checkType(p.getType(), IS_GENERIC)) {
538
697
  tmp.push(expr.getArg(i).getType());
539
698
  }
540
699
  });
@@ -553,12 +712,20 @@ class IRInference {
553
712
  static replaceMethodSignature(init, declared) {
554
713
  const className = init.getDeclaringClassSignature().getClassName();
555
714
  let classSignature;
556
- if (declared.getDeclaringClassSignature().getClassName().endsWith('Interface')) {
715
+ // display 归一化:仅当 init 类名有信息量(非 %unk——组件 create/pop 的 init 由组件名直构)时包 alias。普通 interface 解析(init 为 %unk stub,
716
+ // 如 TestInterface.callf)直接用 declared——alias 会把显示退化为 %unk。
717
+ if (className !== Const_1.UNKNOWN_CLASS_NAME && declared.getDeclaringClassSignature().getClassName().endsWith('Interface')) {
557
718
  classSignature = new ArkSignature_1.AliasClassSignature(className, declared.getDeclaringClassSignature());
558
719
  }
559
720
  let newSubSignature;
560
721
  if (classSignature || newSubSignature) {
561
- return new ArkSignature_1.MethodSignature(classSignature !== null && classSignature !== void 0 ? classSignature : declared.getDeclaringClassSignature(), newSubSignature !== null && newSubSignature !== void 0 ? newSubSignature : declared.getMethodSubSignature());
722
+ const result = new ArkSignature_1.MethodSignature(classSignature !== null && classSignature !== void 0 ? classSignature : declared.getDeclaringClassSignature(), newSubSignature !== null && newSubSignature !== void 0 ? newSubSignature : declared.getMethodSubSignature());
723
+ // display 归一化:alias 产物 intern formal + 双注册 declared 的 ArkMethod model——expr 的 route() formal 命中持 SigID(display 由 formal
724
+ // canonical 自持,不再依赖 expr 锚定传入实例)。
725
+ if (classSignature !== undefined) {
726
+ (0, ArkSignature_1.internAliasMethodSignature)(result, declared);
727
+ }
728
+ return result;
562
729
  }
563
730
  return declared;
564
731
  }
@@ -585,7 +752,7 @@ class IRInference {
585
752
  }
586
753
  }
587
754
  static inferLocal(base, arkMethod) {
588
- var _a, _b;
755
+ var _a;
589
756
  const arkClass = arkMethod.getDeclaringArkClass();
590
757
  let baseType = base.getType();
591
758
  if (baseType instanceof Type_1.UnclearReferenceType) {
@@ -594,7 +761,7 @@ class IRInference {
594
761
  else if (TypeInference_1.TypeInference.isUnclearType(baseType)) {
595
762
  const declaringStmt = base.getDeclaringStmt();
596
763
  if (!declaringStmt) {
597
- baseType = (_b = (_a = ModelUtils_1.ModelUtils.findDeclaredLocal(base, arkMethod)) === null || _a === void 0 ? void 0 : _a.getType()) !== null && _b !== void 0 ? _b : TypeInference_1.TypeInference.inferBaseType(base.getName(), arkClass);
764
+ baseType = (_a = ModelUtils_1.ModelUtils.findDeclaredLocalType(base.getName(), arkMethod)) !== null && _a !== void 0 ? _a : TypeInference_1.TypeInference.inferBaseType(base.getName(), arkClass);
598
765
  }
599
766
  }
600
767
  if (baseType instanceof Type_1.UnionType || (baseType && !TypeInference_1.TypeInference.isUnclearType(baseType))) {
@@ -607,7 +774,7 @@ class IRInference {
607
774
  // Convert primitive types to their wrapper class types
608
775
  const name = baseType instanceof Type_1.LiteralType ? typeof baseType.getLiteralName() : baseType.getName();
609
776
  const className = baseType instanceof Type_1.BigIntType ? Builtin_1.Builtin.BIGINT : name.charAt(0).toUpperCase() + name.slice(1);
610
- const arrayClass = arkMethod.getDeclaringArkFile().getScene().getSdkGlobal(className);
777
+ const arrayClass = SdkUtils_1.SdkUtils.getSdkGlobal(className);
611
778
  if (arrayClass instanceof ArkClass_1.ArkClass) {
612
779
  return inferMember(new Type_1.ClassType(arrayClass.getSignature(), arrayClass.getRealTypes()), value, arkMethod);
613
780
  }
@@ -642,9 +809,10 @@ class IRInference {
642
809
  if (type instanceof Type_1.UndefinedType || type instanceof Type_1.NullType) {
643
810
  continue;
644
811
  }
645
- let newFieldSignature = this.generateNewFieldSignature(ref, arkClass, type);
646
- if (!TypeInference_1.TypeInference.isUnclearType(newFieldSignature === null || newFieldSignature === void 0 ? void 0 : newFieldSignature.getType())) {
647
- return newFieldSignature;
812
+ let resolution = this.generateNewFieldSignature(ref, arkClass, type);
813
+ // Union 试探按 resolution.type 判 unclear(formal 分支带定义点 type,params 分支即构造 type——零实例读取)。
814
+ if (resolution !== null && !TypeInference_1.TypeInference.isUnclearType(resolution.type)) {
815
+ return resolution;
648
816
  }
649
817
  }
650
818
  return null;
@@ -653,7 +821,7 @@ class IRInference {
653
821
  return this.generateNewFieldSignature(ref, arkClass, baseType.getOriginalType());
654
822
  }
655
823
  else if (baseType instanceof Type_1.ArrayType) {
656
- const arrayClass = arkClass.getDeclaringArkFile().getScene().getSdkGlobal(Builtin_1.Builtin.ARRAY);
824
+ const arrayClass = SdkUtils_1.SdkUtils.getSdkGlobal(Builtin_1.Builtin.ARRAY);
657
825
  if (arrayClass instanceof ArkClass_1.ArkClass) {
658
826
  baseType = new Type_1.ClassType(arrayClass.getSignature(), [baseType.getBaseType()]);
659
827
  }
@@ -661,77 +829,104 @@ class IRInference {
661
829
  return IRInference.getFieldSignature(ref, baseType, arkClass);
662
830
  }
663
831
  static updateRefSignature(baseType, ref, arkMethod) {
832
+ var _a, _b, _c;
664
833
  const fieldName = ref.getFieldName().replace(/[\"|\']/g, '');
665
834
  if (baseType instanceof Type_1.TupleType) {
666
- const n = Number(fieldName);
667
- if (!isNaN(n) && n < baseType.getTypes().length) {
668
- ref.getFieldSignature().setType(baseType.getTypes()[n]);
669
- }
670
- return ref;
835
+ return this.updateTupleElementType(ref, fieldName, baseType);
671
836
  }
672
- else if (baseType instanceof Type_1.ArrayType) {
837
+ if (baseType instanceof Type_1.ArrayType) {
673
838
  if (ref instanceof Ref_1.ArkInstanceFieldRef && ref.isDynamic()) {
674
- const index = TypeInference_1.TypeInference.getLocalFromMethodBody(fieldName, arkMethod);
675
- return new Ref_1.ArkArrayRef(ref.getBase(), index !== null && index !== void 0 ? index : ValueUtil_1.ValueUtil.createConst(fieldName));
839
+ // dynamic ref 被 ArkArrayRef 替换——纯 retire。
840
+ ref.retireTemp();
841
+ return new Ref_1.ArkArrayRef(ref.getBase(), (_a = TypeInference_1.TypeInference.getLocalFromMethodBody(fieldName, arkMethod)) !== null && _a !== void 0 ? _a : ValueUtil_1.ValueUtil.createConst(fieldName));
676
842
  }
677
- else {
678
- const arrayClass = arkMethod.getDeclaringArkFile().getScene().getSdkGlobal(Builtin_1.Builtin.ARRAY);
679
- if (arrayClass instanceof ArkClass_1.ArkClass) {
680
- baseType = new Type_1.ClassType(arrayClass.getSignature(), [baseType.getBaseType()]);
681
- }
843
+ const arrayClass = SdkUtils_1.SdkUtils.getSdkGlobal(Builtin_1.Builtin.ARRAY);
844
+ if (arrayClass instanceof ArkClass_1.ArkClass) {
845
+ baseType = new Type_1.ClassType(arrayClass.getSignature(), [baseType.getBaseType()]);
682
846
  }
683
847
  }
684
848
  else if (baseType instanceof Type_1.FunctionType) {
685
- const arrayClass = arkMethod.getDeclaringArkFile().getScene().getSdkGlobal(Builtin_1.Builtin.FUNCTION);
849
+ const arrayClass = SdkUtils_1.SdkUtils.getSdkGlobal(Builtin_1.Builtin.FUNCTION);
686
850
  if (arrayClass instanceof ArkClass_1.ArkClass) {
687
851
  baseType = new Type_1.ClassType(arrayClass.getSignature());
688
852
  }
689
853
  }
690
- let { staticFlag, signature, value } = IRInference.genFieldSignature(fieldName, baseType, ref, arkMethod);
691
- if (value) {
692
- return value;
693
- }
694
- if (!signature) {
854
+ const resolution = IRInference.genFieldSignature(fieldName, baseType, ref, arkMethod);
855
+ if (resolution === null || (resolution.kind === 'formal' && ((_b = resolution.formalId) !== null && _b !== void 0 ? _b : 0) <= 0)) {
695
856
  return null;
696
857
  }
697
- if (staticFlag) {
698
- return new Ref_1.ArkStaticFieldRef(signature);
858
+ if (resolution.kind === 'getter') {
859
+ // 替换埋葬:getter 裸引用被 invokeExpr 替换——纯 retire(产物无字段归宿)。
860
+ ref.retireTemp();
861
+ return resolution.value;
699
862
  }
700
- else {
701
- ref.setFieldSignature(signature);
863
+ if (resolution.kind === 'params') {
864
+ if (resolution.staticFlag) {
865
+ return IRInference.applyStaticParamsResolution(ref, resolution);
866
+ }
867
+ ref.updateFieldSignature(resolution.fieldName, resolution.declaringOrID, resolution.type, resolution.staticFlag, resolution.namespaceDeclared);
702
868
  return ref;
703
869
  }
870
+ const formalId = (_c = resolution.formalId) !== null && _c !== void 0 ? _c : 0;
871
+ if (resolution.staticFlag) {
872
+ ref.retireTempTo(formalId);
873
+ return new Ref_1.ArkStaticFieldRef(SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance().fieldSigCanonicalizer.get(formalId));
874
+ }
875
+ ref.graduateToFormal(formalId);
876
+ return ref;
877
+ }
878
+ /** TupleType 前置:元组索引字段的类型直写('0'/'1' → 对应元素类型)。 */
879
+ static updateTupleElementType(ref, fieldName, baseType) {
880
+ const n = Number(fieldName);
881
+ if (!isNaN(n) && n < baseType.getTypes().length) {
882
+ ref.getFieldSignature().setType(baseType.getTypes()[n]);
883
+ }
884
+ return ref;
704
885
  }
705
886
  static genFieldSignature(fieldName, baseType, ref, arkMethod) {
706
887
  var _a;
707
888
  const arkClass = arkMethod.getDeclaringArkClass();
708
889
  const propertyAndType = TypeInference_1.TypeInference.inferFieldType(baseType, fieldName, arkClass);
709
890
  let propertyType = IRInference.repairType(propertyAndType === null || propertyAndType === void 0 ? void 0 : propertyAndType[1], fieldName, arkClass);
710
- let staticFlag = false;
711
- let signature = null;
712
891
  if (baseType instanceof Type_1.ClassType) {
713
892
  const property = (_a = propertyAndType === null || propertyAndType === void 0 ? void 0 : propertyAndType[0]) !== null && _a !== void 0 ? _a : IRInference.findPropertyFormChildrenClass(fieldName, arkClass, baseType);
714
893
  if (property instanceof ArkMethod_1.ArkMethod && property.getName().startsWith(Const_1.GETTER_PREFIX) && ref instanceof Ref_1.ArkInstanceFieldRef) {
715
- const expr = property.isStatic() ? new Expr_1.ArkStaticInvokeExpr(property.getSignature(), [])
894
+ const expr = property.isStatic()
895
+ ? new Expr_1.ArkStaticInvokeExpr(property.getSignature(), [])
716
896
  : new Expr_1.ArkInstanceInvokeExpr(ref.getBase(), property.getSignature(), []);
717
- return { staticFlag: staticFlag, signature: signature, value: expr };
897
+ return { kind: 'getter', value: expr };
718
898
  }
719
- staticFlag = baseType.getClassSignature().getClassName() === Const_1.DEFAULT_ARK_CLASS_NAME ||
899
+ const staticFlag = baseType.getClassSignature().getClassName() === Const_1.DEFAULT_ARK_CLASS_NAME ||
720
900
  ((property instanceof ArkField_1.ArkField || property instanceof ArkMethod_1.ArkMethod) && property.isStatic());
721
- if (property instanceof ArkField_1.ArkField && property.getCategory() !== ArkField_1.FieldCategory.ENUM_MEMBER &&
722
- !(property.getType() instanceof Type_1.GenericType)) {
723
- signature = property.getSignature();
724
- }
725
- else {
726
- const baseSignature = property instanceof ArkMethod_1.ArkMethod ? property.getSignature().getDeclaringClassSignature() : baseType.getClassSignature();
727
- signature = new ArkSignature_1.FieldSignature(fieldName, baseSignature, propertyType !== null && propertyType !== void 0 ? propertyType : ref.getType(), staticFlag);
901
+ if (property instanceof ArkField_1.ArkField && property.getCategory() !== ArkField_1.FieldCategory.ENUM_MEMBER) {
902
+ // 非泛型与泛型字段统一用定义点签名(formal 身份)。泛型字段(定义点 type 为 GenericType)的使用点实例化由 ref.realFieldTypes 承载
903
+ // (Expr.realGenericTypes 同构,getType() 动态组合)。实参表从 baseType 提取(与 inferFieldType 的 replaceTypeWithReal 同源)。
904
+ // 实参表残留无害:getType 的 Generic/Any 守卫使非泛型 type 不受影响。
905
+ if (property.getType() instanceof Type_1.GenericType) {
906
+ ref.setRealFieldTypes(baseType.getRealGenericTypes());
907
+ }
908
+ let fieldType = property.getType();
909
+ if (TypeInference_1.TypeInference.isUnclearType(fieldType)) {
910
+ fieldType = this.refineFieldTypeFromBaseInitializer(ref, property, fieldName, fieldType, arkMethod);
911
+ }
912
+ return { kind: 'formal', formalId: property.getFieldSigID(), staticFlag, type: fieldType };
728
913
  }
914
+ // getClassSignature() (not getClassSigID()): the class may still be unclear and
915
+ // live in the temp canonicalizer; the object overload interns it properly.
916
+ const baseSignature = property instanceof ArkMethod_1.ArkMethod ? property.getSignature().getDeclaringClassSignature() : baseType.getClassSignature();
917
+ return { kind: 'params', fieldName, declaringOrID: baseSignature, type: propertyType !== null && propertyType !== void 0 ? propertyType : ref.getType(), staticFlag, namespaceDeclared: false };
729
918
  }
730
919
  else if (baseType instanceof Type_1.AnnotationNamespaceType) {
731
- staticFlag = true;
732
- signature = new ArkSignature_1.FieldSignature(fieldName, baseType.getNamespaceSignature(), propertyType !== null && propertyType !== void 0 ? propertyType : ref.getType(), staticFlag);
920
+ return {
921
+ kind: 'params',
922
+ fieldName,
923
+ declaringOrID: baseType.getNamespaceSignature().getNamespaceSigID(),
924
+ type: propertyType !== null && propertyType !== void 0 ? propertyType : ref.getType(),
925
+ staticFlag: true,
926
+ namespaceDeclared: true,
927
+ };
733
928
  }
734
- return { staticFlag, signature };
929
+ return null;
735
930
  }
736
931
  static getFieldSignature(ref, baseType, arkClass) {
737
932
  const fieldName = ref.getFieldName().replace(/[\"|\']/g, '');
@@ -747,17 +942,33 @@ class IRInference {
747
942
  property = subField;
748
943
  }
749
944
  }
750
- else if (property instanceof ArkField_1.ArkField && property.getCategory() !== ArkField_1.FieldCategory.ENUM_MEMBER &&
751
- !(property.getType() instanceof Type_1.GenericType)) {
752
- return property.getSignature();
753
- }
754
- staticFlag = baseType.getClassSignature().getClassName() === Const_1.DEFAULT_ARK_CLASS_NAME ||
755
- ((property instanceof ArkField_1.ArkField || property instanceof ArkMethod_1.ArkMethod) && property.isStatic());
945
+ else if (property instanceof ArkField_1.ArkField && property.getCategory() !== ArkField_1.FieldCategory.ENUM_MEMBER) {
946
+ // 非泛型与泛型字段统一返回定义点签名;泛型字段的使用点实例化由 ref.realFieldTypes 承载(与 genFieldSignature 分支同构)。
947
+ if (property.getType() instanceof Type_1.GenericType) {
948
+ ref.setRealFieldTypes(baseType.getRealGenericTypes());
949
+ }
950
+ let fieldType = property.getType();
951
+ if (TypeInference_1.TypeInference.isUnclearType(fieldType)) {
952
+ fieldType = this.refineFieldTypeFromBaseInitializer(ref, property, fieldName, fieldType);
953
+ }
954
+ // 定义点 canonical——formalId 直读(终点确定)。
955
+ return { kind: 'formal', formalId: property.getFieldSigID(), staticFlag: property.isStatic(), type: fieldType };
956
+ }
957
+ staticFlag =
958
+ baseType.getClassSignature().getClassName() === Const_1.DEFAULT_ARK_CLASS_NAME ||
959
+ ((property instanceof ArkField_1.ArkField || property instanceof ArkMethod_1.ArkMethod) && property.isStatic());
960
+ // Note: baseType.getClassSignature() (not getClassSigID()) — the class may still be
961
+ // unclear and live in the temp canonicalizer (classSigID === -1); the object overload
962
+ // interns it properly.
756
963
  signature = property instanceof ArkMethod_1.ArkMethod ? property.getSignature().getDeclaringClassSignature() : baseType.getClassSignature();
757
964
  }
758
965
  else if (baseType instanceof Type_1.ArrayType) {
759
966
  const property = propertyAndType === null || propertyAndType === void 0 ? void 0 : propertyAndType[0];
760
- return property instanceof ArkField_1.ArkField ? property.getSignature() : null;
967
+ if (property instanceof ArkField_1.ArkField) {
968
+ // 定义点 canonical(Array 字段)。
969
+ return { kind: 'formal', formalId: property.getFieldSigID(), staticFlag: property.isStatic(), type: property.getType() };
970
+ }
971
+ return null;
761
972
  }
762
973
  else if (baseType instanceof Type_1.AnnotationNamespaceType) {
763
974
  staticFlag = true;
@@ -766,24 +977,80 @@ class IRInference {
766
977
  else {
767
978
  return null;
768
979
  }
769
- return new ArkSignature_1.FieldSignature(fieldName, signature, propertyType !== null && propertyType !== void 0 ? propertyType : ref.getType(), staticFlag);
980
+ // 新构造值(终点不确定)——参数元组。
981
+ return signature instanceof ArkSignature_1.NamespaceSignature
982
+ ? {
983
+ kind: 'params',
984
+ fieldName,
985
+ declaringOrID: signature.getNamespaceSigID(),
986
+ type: propertyType !== null && propertyType !== void 0 ? propertyType : ref.getType(),
987
+ staticFlag,
988
+ namespaceDeclared: true,
989
+ }
990
+ : { kind: 'params', fieldName, declaringOrID: signature, type: propertyType !== null && propertyType !== void 0 ? propertyType : ref.getType(), staticFlag, namespaceDeclared: false };
991
+ }
992
+ /**
993
+ * 声明类型路径的字段类型 unclear(如 interface 无标注字段的声明类型路径)时的值类型精化:
994
+ * base local 的初始化 stmt(declaringStmt)右值类型是 clear ClassType(对象字面量匿名类等)
995
+ * 时,取值类型上同名字段的定义点类型回填。fieldSig 保持声明锚定不变,仅经精度栅栏单向
996
+ * 精化 formal canonical 的类型(unclear → clear,与 AbstractFieldRef.route 的栅栏同语义)。
997
+ * base 是全局变量的使用点 local(无方法内定义 stmt)时,经 findDeclaredLocal 桥接文件级
998
+ * def local(顶层 const 的初始化在 default 方法中)。
999
+ */
1000
+ static refineFieldTypeFromBaseInitializer(ref, property, fieldName, unclearType, arkMethod) {
1001
+ if (!(ref instanceof Ref_1.ArkInstanceFieldRef)) {
1002
+ return unclearType;
1003
+ }
1004
+ const base = ref.getBase();
1005
+ if (!(base instanceof Local_1.Local)) {
1006
+ return unclearType;
1007
+ }
1008
+ let declaringStmt = base.getDeclaringStmt();
1009
+ if (!(declaringStmt instanceof Stmt_1.ArkAssignStmt) && arkMethod !== undefined) {
1010
+ const declaredLocal = ModelUtils_1.ModelUtils.findDeclaredLocal(base, arkMethod, 1);
1011
+ const declaredStmt = declaredLocal === null || declaredLocal === void 0 ? void 0 : declaredLocal.getDeclaringStmt();
1012
+ if (declaredStmt instanceof Stmt_1.ArkAssignStmt) {
1013
+ declaringStmt = declaredStmt;
1014
+ }
1015
+ }
1016
+ if (!(declaringStmt instanceof Stmt_1.ArkAssignStmt)) {
1017
+ return unclearType;
1018
+ }
1019
+ const valueType = declaringStmt.getRightOp().getType();
1020
+ if (!(valueType instanceof Type_1.ClassType) || TypeInference_1.TypeInference.isUnclearType(valueType)) {
1021
+ return unclearType;
1022
+ }
1023
+ const registry = SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance();
1024
+ const valueClass = registry.getClassById(valueType.getClassSigID());
1025
+ const valueField = valueClass === null || valueClass === void 0 ? void 0 : valueClass.getFieldWithName(fieldName);
1026
+ if (!valueField) {
1027
+ return unclearType;
1028
+ }
1029
+ const refinedType = valueField.getType();
1030
+ if (TypeInference_1.TypeInference.isUnclearType(refinedType)) {
1031
+ return unclearType;
1032
+ }
1033
+ const canonical = registry.fieldSigCanonicalizer.get(property.getFieldSigID());
1034
+ if (canonical !== undefined && canonical.getType().isUnclear()) {
1035
+ canonical.setType(refinedType);
1036
+ }
1037
+ return refinedType;
770
1038
  }
771
1039
  static findPropertyFormChildrenClass(fieldName, arkClass, baseType) {
772
1040
  var _a;
773
- if (baseType.getClassSignature().getClassName() !== Const_1.DEFAULT_ARK_CLASS_NAME &&
774
- baseType.getClassSignature().getDeclaringFileSignature().getProjectName() !== Builtin_1.Builtin.DUMMY_PROJECT_NAME) {
775
- const iterator = (_a = arkClass.getDeclaringArkFile().getScene().getClass(baseType.getClassSignature())) === null || _a === void 0 ? void 0 : _a.getExtendedClasses().values();
776
- if (!iterator) {
1041
+ const registry = SignatureCanonicalizerRegistry_1.SignatureCanonicalizerRegistry.getInstance();
1042
+ if (baseType.getClassSignature().getClassName() !== Const_1.DEFAULT_ARK_CLASS_NAME) {
1043
+ // Unclear stubs have no formal model, so getClassBySig returns undefined for
1044
+ // them — the extended-class lookup below is naturally skipped (read-only lookup).
1045
+ const extendedClasses = (_a = registry.getClassBySig(baseType.getClassSignature())) === null || _a === void 0 ? void 0 : _a.getExtendedClassList();
1046
+ if (!extendedClasses) {
777
1047
  return null;
778
1048
  }
779
- let next = iterator.next();
780
- while (!next.done) {
781
- const subClass = next.value;
1049
+ for (const subClass of extendedClasses) {
782
1050
  const property = TypeInference_1.TypeInference.inferFieldType(new Type_1.ClassType(subClass.getSignature(), subClass.getRealTypes()), fieldName, subClass);
783
1051
  if (property && property[0]) {
784
1052
  return property[0];
785
1053
  }
786
- next = iterator.next();
787
1054
  }
788
1055
  }
789
1056
  return null;
@@ -830,7 +1097,9 @@ class IRInference {
830
1097
  this.assignAnonMethod(scene.getMethod(type.getMethodSignature()), property);
831
1098
  }
832
1099
  if (type instanceof Type_1.UnknownType) {
833
- anonField.setSignature(new ArkSignature_1.FieldSignature(anonField.getName(), property.getDeclaringArkClass().getSignature(), new Type_1.FunctionType(property.getSignature())));
1100
+ // 类型对齐而非签名过户:同 assignAnonField——只补类型,不把匿名字段
1101
+ // intern 到声明类名下(防 model 顶替写穿)。
1102
+ anonField.getSignature().setType(new Type_1.FunctionType(property.getSignature()));
834
1103
  }
835
1104
  }
836
1105
  }
@@ -872,10 +1141,22 @@ class IRInference {
872
1141
  }
873
1142
  const leftOp = lastStmt.getLeftOp();
874
1143
  if (leftOp instanceof Ref_1.AbstractFieldRef) {
875
- leftOp.setFieldSignature(property.getSignature());
876
- }
1144
+ // A2 快路径:定义点 canonical 回写(property 为 ArkField,ID 直读)。
1145
+ leftOp.graduateToFormal(property.getFieldSigID());
1146
+ }
1147
+ }
1148
+ // 类型对齐而非签名过户:只把声明侧类型拷贝到匿名类字段的自有 canonical 签名
1149
+ //(type 不参与 FieldSignature 的 hash/equals,改动无 ID 影响)。不再
1150
+ // setSignature(property.getSignature())——那会把匿名字段注册到 SDK 字段的
1151
+ // FieldSigID 名下、顶替其全局 model,导致 SDK 类字段视图读到匿名字段实例
1152
+ //(initializer 写穿,见对象字面量赋值 SDK 类型的回归用例)。
1153
+ // 精确类型优先(narrowing):initializer 已推导出的精确类型(枚举成员
1154
+ // EnumValueType、number、string 等)保留;SDK 声明类型仅在匿名字段自身
1155
+ // 类型仍 unclear/unknown 时兜底(对齐 resolveLeftOp 对 localDef 的
1156
+ // "只增强、不覆盖"守卫模式)。
1157
+ if (TypeInference_1.TypeInference.isUnclearType(anonField.getSignature().getType())) {
1158
+ anonField.getSignature().setType(property.getSignature().getType());
877
1159
  }
878
- anonField.setSignature(property.getSignature());
879
1160
  }
880
1161
  static inferAliasTypeExpr(expr, arkMethod) {
881
1162
  const originalObject = expr.getOriginalObject();