@geastack/compiler 1.0.15

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 (966) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +149 -0
  3. package/dist/cli-analyze.d.ts +1 -0
  4. package/dist/cli-analyze.js +61 -0
  5. package/dist/cli-coverage.d.ts +1 -0
  6. package/dist/cli-coverage.js +329 -0
  7. package/dist/cli-emit.d.ts +10 -0
  8. package/dist/cli-emit.js +398 -0
  9. package/dist/cli-module-graph.d.ts +18 -0
  10. package/dist/cli-module-graph.js +123 -0
  11. package/dist/cli-package-source.d.ts +5 -0
  12. package/dist/cli-package-source.js +116 -0
  13. package/dist/cli-project.d.ts +2 -0
  14. package/dist/cli-project.js +60 -0
  15. package/dist/cli.d.ts +2 -0
  16. package/dist/cli.js +199 -0
  17. package/dist/compiler.d.ts +228 -0
  18. package/dist/compiler.js +1029 -0
  19. package/dist/conversion/algebra.d.ts +218 -0
  20. package/dist/conversion/algebra.js +155 -0
  21. package/dist/conversion/build.d.ts +67 -0
  22. package/dist/conversion/build.js +1378 -0
  23. package/dist/conversion/derive.d.ts +37 -0
  24. package/dist/conversion/derive.js +260 -0
  25. package/dist/conversion/graph-validation.d.ts +8 -0
  26. package/dist/conversion/graph-validation.js +97 -0
  27. package/dist/conversion/native-callable-adapter.d.ts +13 -0
  28. package/dist/conversion/native-callable-adapter.js +53 -0
  29. package/dist/conversion/native-class-reference.d.ts +12 -0
  30. package/dist/conversion/native-class-reference.js +39 -0
  31. package/dist/conversion/native-payload-transport.d.ts +25 -0
  32. package/dist/conversion/native-payload-transport.js +33 -0
  33. package/dist/conversion/native-selection.d.ts +49 -0
  34. package/dist/conversion/native-selection.js +135 -0
  35. package/dist/conversion/native-sum.d.ts +42 -0
  36. package/dist/conversion/native-sum.js +115 -0
  37. package/dist/conversion/nodes.d.ts +55 -0
  38. package/dist/conversion/nodes.js +91 -0
  39. package/dist/conversion/operand-view.d.ts +14 -0
  40. package/dist/conversion/operand-view.js +20 -0
  41. package/dist/conversion/record-view.d.ts +157 -0
  42. package/dist/conversion/record-view.js +273 -0
  43. package/dist/conversion/registry.d.ts +217 -0
  44. package/dist/conversion/registry.js +1 -0
  45. package/dist/diagnostics/model.d.ts +76 -0
  46. package/dist/diagnostics/model.js +60 -0
  47. package/dist/diagnostics/sweep.d.ts +31 -0
  48. package/dist/diagnostics/sweep.js +112 -0
  49. package/dist/identity/ids.d.ts +179 -0
  50. package/dist/identity/ids.js +212 -0
  51. package/dist/ir/absent-class-arm.d.ts +48 -0
  52. package/dist/ir/absent-class-arm.js +157 -0
  53. package/dist/ir/borrow-effects.d.ts +23 -0
  54. package/dist/ir/borrow-effects.js +151 -0
  55. package/dist/ir/borrowed-call-arguments.d.ts +40 -0
  56. package/dist/ir/borrowed-call-arguments.js +117 -0
  57. package/dist/ir/build.d.ts +168 -0
  58. package/dist/ir/build.js +459 -0
  59. package/dist/ir/call-dispatch.d.ts +38 -0
  60. package/dist/ir/call-dispatch.js +502 -0
  61. package/dist/ir/call-entry.d.ts +142 -0
  62. package/dist/ir/call-entry.js +386 -0
  63. package/dist/ir/callable-class-flow.d.ts +27 -0
  64. package/dist/ir/callable-class-flow.js +1386 -0
  65. package/dist/ir/callable-field-slots.d.ts +22 -0
  66. package/dist/ir/callable-field-slots.js +166 -0
  67. package/dist/ir/callable-identity-demand.d.ts +52 -0
  68. package/dist/ir/callable-identity-demand.js +460 -0
  69. package/dist/ir/callable-member-candidates.d.ts +9 -0
  70. package/dist/ir/callable-member-candidates.js +39 -0
  71. package/dist/ir/callable-records.d.ts +21 -0
  72. package/dist/ir/callable-records.js +411 -0
  73. package/dist/ir/captures.d.ts +26 -0
  74. package/dist/ir/captures.js +335 -0
  75. package/dist/ir/certificate.d.ts +45 -0
  76. package/dist/ir/certificate.js +47 -0
  77. package/dist/ir/certify/carrier-keys.d.ts +73 -0
  78. package/dist/ir/certify/carrier-keys.js +221 -0
  79. package/dist/ir/certify/function-source.d.ts +4 -0
  80. package/dist/ir/certify/function-source.js +28 -0
  81. package/dist/ir/certify/has-property-key.d.ts +88 -0
  82. package/dist/ir/certify/has-property-key.js +116 -0
  83. package/dist/ir/certify/instanceof-key.d.ts +24 -0
  84. package/dist/ir/certify/instanceof-key.js +35 -0
  85. package/dist/ir/certify/property-access-keys.d.ts +172 -0
  86. package/dist/ir/certify/property-access-keys.js +291 -0
  87. package/dist/ir/certify/property-access.d.ts +3 -0
  88. package/dist/ir/certify/property-access.js +597 -0
  89. package/dist/ir/certify/runtime-helper.d.ts +3 -0
  90. package/dist/ir/certify/runtime-helper.js +326 -0
  91. package/dist/ir/certify/typeof-operand.d.ts +14 -0
  92. package/dist/ir/certify/typeof-operand.js +16 -0
  93. package/dist/ir/certify.d.ts +123 -0
  94. package/dist/ir/certify.js +481 -0
  95. package/dist/ir/class-evaluation.d.ts +26 -0
  96. package/dist/ir/class-evaluation.js +50 -0
  97. package/dist/ir/class-static-fields.d.ts +60 -0
  98. package/dist/ir/class-static-fields.js +108 -0
  99. package/dist/ir/construct-entry.d.ts +26 -0
  100. package/dist/ir/construct-entry.js +117 -0
  101. package/dist/ir/dead-values.d.ts +90 -0
  102. package/dist/ir/dead-values.js +184 -0
  103. package/dist/ir/deferral.d.ts +99 -0
  104. package/dist/ir/deferral.js +409 -0
  105. package/dist/ir/dense-loops.d.ts +230 -0
  106. package/dist/ir/dense-loops.js +697 -0
  107. package/dist/ir/dominance.d.ts +82 -0
  108. package/dist/ir/dominance.js +268 -0
  109. package/dist/ir/emission-representations.d.ts +71 -0
  110. package/dist/ir/emission-representations.js +350 -0
  111. package/dist/ir/facts.d.ts +218 -0
  112. package/dist/ir/facts.js +181 -0
  113. package/dist/ir/fixed-data-definition.d.ts +19 -0
  114. package/dist/ir/fixed-data-definition.js +49 -0
  115. package/dist/ir/generator-split.d.ts +38 -0
  116. package/dist/ir/generator-split.js +329 -0
  117. package/dist/ir/hoist.d.ts +55 -0
  118. package/dist/ir/hoist.js +375 -0
  119. package/dist/ir/instantiation.d.ts +61 -0
  120. package/dist/ir/instantiation.js +137 -0
  121. package/dist/ir/integer-storage.d.ts +170 -0
  122. package/dist/ir/integer-storage.js +822 -0
  123. package/dist/ir/integers.d.ts +161 -0
  124. package/dist/ir/integers.js +539 -0
  125. package/dist/ir/integrity-restrictions.d.ts +50 -0
  126. package/dist/ir/integrity-restrictions.js +118 -0
  127. package/dist/ir/local-iterators.d.ts +4 -0
  128. package/dist/ir/local-iterators.js +27 -0
  129. package/dist/ir/lower-allocation.d.ts +4 -0
  130. package/dist/ir/lower-allocation.js +325 -0
  131. package/dist/ir/lower-completion.d.ts +15 -0
  132. package/dist/ir/lower-completion.js +25 -0
  133. package/dist/ir/lower-destructuring.d.ts +5 -0
  134. package/dist/ir/lower-destructuring.js +693 -0
  135. package/dist/ir/lower-element.d.ts +29 -0
  136. package/dist/ir/lower-element.js +111 -0
  137. package/dist/ir/lower-exceptions.d.ts +47 -0
  138. package/dist/ir/lower-exceptions.js +92 -0
  139. package/dist/ir/lower-flow.d.ts +137 -0
  140. package/dist/ir/lower-flow.js +600 -0
  141. package/dist/ir/lower-graph.d.ts +218 -0
  142. package/dist/ir/lower-graph.js +687 -0
  143. package/dist/ir/lower-invocation.d.ts +4 -0
  144. package/dist/ir/lower-invocation.js +514 -0
  145. package/dist/ir/lower-narrow.d.ts +53 -0
  146. package/dist/ir/lower-narrow.js +320 -0
  147. package/dist/ir/lower-operands.d.ts +272 -0
  148. package/dist/ir/lower-operands.js +461 -0
  149. package/dist/ir/lower-property.d.ts +21 -0
  150. package/dist/ir/lower-property.js +132 -0
  151. package/dist/ir/lower-protocol.d.ts +11 -0
  152. package/dist/ir/lower-protocol.js +118 -0
  153. package/dist/ir/lower-short-circuit.d.ts +41 -0
  154. package/dist/ir/lower-short-circuit.js +63 -0
  155. package/dist/ir/lower.d.ts +82 -0
  156. package/dist/ir/lower.js +1346 -0
  157. package/dist/ir/model.d.ts +1474 -0
  158. package/dist/ir/model.js +6 -0
  159. package/dist/ir/native-absent-property.d.ts +3 -0
  160. package/dist/ir/native-absent-property.js +13 -0
  161. package/dist/ir/native-array-transport.d.ts +7 -0
  162. package/dist/ir/native-array-transport.js +46 -0
  163. package/dist/ir/native-callable-bind.d.ts +9 -0
  164. package/dist/ir/native-callable-bind.js +30 -0
  165. package/dist/ir/native-carrier-predicate.d.ts +34 -0
  166. package/dist/ir/native-carrier-predicate.js +49 -0
  167. package/dist/ir/native-class-accessor.d.ts +18 -0
  168. package/dist/ir/native-class-accessor.js +52 -0
  169. package/dist/ir/native-class-construction.d.ts +16 -0
  170. package/dist/ir/native-class-construction.js +71 -0
  171. package/dist/ir/native-class-initialization.d.ts +15 -0
  172. package/dist/ir/native-class-initialization.js +56 -0
  173. package/dist/ir/native-class-origins.d.ts +13 -0
  174. package/dist/ir/native-class-origins.js +237 -0
  175. package/dist/ir/native-dictionary-transport.d.ts +6 -0
  176. package/dist/ir/native-dictionary-transport.js +37 -0
  177. package/dist/ir/native-enumeration.d.ts +14 -0
  178. package/dist/ir/native-enumeration.js +26 -0
  179. package/dist/ir/native-equality.d.ts +10 -0
  180. package/dist/ir/native-equality.js +18 -0
  181. package/dist/ir/native-field-owner.d.ts +37 -0
  182. package/dist/ir/native-field-owner.js +183 -0
  183. package/dist/ir/native-fixed-layout.d.ts +41 -0
  184. package/dist/ir/native-fixed-layout.js +232 -0
  185. package/dist/ir/native-host-construction.d.ts +53 -0
  186. package/dist/ir/native-host-construction.js +62 -0
  187. package/dist/ir/native-key-query.d.ts +4 -0
  188. package/dist/ir/native-key-query.js +38 -0
  189. package/dist/ir/native-merge-transport.d.ts +25 -0
  190. package/dist/ir/native-merge-transport.js +71 -0
  191. package/dist/ir/native-record-index-transport.d.ts +11 -0
  192. package/dist/ir/native-record-index-transport.js +34 -0
  193. package/dist/ir/native-record-index.d.ts +12 -0
  194. package/dist/ir/native-record-index.js +27 -0
  195. package/dist/ir/native-reflect-field.d.ts +5 -0
  196. package/dist/ir/native-reflect-field.js +33 -0
  197. package/dist/ir/native-sequence-transport.d.ts +7 -0
  198. package/dist/ir/native-sequence-transport.js +53 -0
  199. package/dist/ir/numeric-intrinsics.d.ts +13 -0
  200. package/dist/ir/numeric-intrinsics.js +57 -0
  201. package/dist/ir/object-value-conversions.d.ts +20 -0
  202. package/dist/ir/object-value-conversions.js +50 -0
  203. package/dist/ir/physical-class-reflection.d.ts +9 -0
  204. package/dist/ir/physical-class-reflection.js +57 -0
  205. package/dist/ir/presence-proof.d.ts +42 -0
  206. package/dist/ir/presence-proof.js +490 -0
  207. package/dist/ir/program-facts.d.ts +106 -0
  208. package/dist/ir/program-facts.js +319 -0
  209. package/dist/ir/proven-branches.d.ts +16 -0
  210. package/dist/ir/proven-branches.js +219 -0
  211. package/dist/ir/queries.d.ts +41 -0
  212. package/dist/ir/queries.js +213 -0
  213. package/dist/ir/reflection-demand.d.ts +64 -0
  214. package/dist/ir/reflection-demand.js +1394 -0
  215. package/dist/ir/refusal.d.ts +43 -0
  216. package/dist/ir/refusal.js +28 -0
  217. package/dist/ir/shake.d.ts +37 -0
  218. package/dist/ir/shake.js +1078 -0
  219. package/dist/ir/static-callables.d.ts +11 -0
  220. package/dist/ir/static-callables.js +163 -0
  221. package/dist/ir/string-layout-reuse.d.ts +13 -0
  222. package/dist/ir/string-layout-reuse.js +39 -0
  223. package/dist/ir/string-length-reuse.d.ts +8 -0
  224. package/dist/ir/string-length-reuse.js +47 -0
  225. package/dist/ir/transfer.d.ts +78 -0
  226. package/dist/ir/transfer.js +270 -0
  227. package/dist/ir/type-query-results.d.ts +25 -0
  228. package/dist/ir/type-query-results.js +96 -0
  229. package/dist/ir/typed-property-access.d.ts +100 -0
  230. package/dist/ir/typed-property-access.js +161 -0
  231. package/dist/ir/verify.d.ts +19 -0
  232. package/dist/ir/verify.js +355 -0
  233. package/dist/plugins/apple/constructors.d.ts +112 -0
  234. package/dist/plugins/apple/constructors.js +217 -0
  235. package/dist/plugins/apple/host.d.ts +181 -0
  236. package/dist/plugins/apple/host.js +262 -0
  237. package/dist/plugins/apple/jsx.d.ts +2 -0
  238. package/dist/plugins/apple/jsx.js +293 -0
  239. package/dist/plugins/apple/members.d.ts +16 -0
  240. package/dist/plugins/apple/members.js +190 -0
  241. package/dist/plugins/apple/plugin.d.ts +2 -0
  242. package/dist/plugins/apple/plugin.js +156 -0
  243. package/dist/plugins/gea/component-classes.d.ts +25 -0
  244. package/dist/plugins/gea/component-classes.js +162 -0
  245. package/dist/plugins/gea/component-inline.d.ts +13 -0
  246. package/dist/plugins/gea/component-inline.js +532 -0
  247. package/dist/plugins/gea/constructors.d.ts +23 -0
  248. package/dist/plugins/gea/constructors.js +100 -0
  249. package/dist/plugins/gea/contract.d.ts +150 -0
  250. package/dist/plugins/gea/contract.js +195 -0
  251. package/dist/plugins/gea/element-ref.d.ts +31 -0
  252. package/dist/plugins/gea/element-ref.js +45 -0
  253. package/dist/plugins/gea/host.d.ts +520 -0
  254. package/dist/plugins/gea/host.js +762 -0
  255. package/dist/plugins/gea/lower.d.ts +6 -0
  256. package/dist/plugins/gea/lower.js +195 -0
  257. package/dist/plugins/gea/members.d.ts +22 -0
  258. package/dist/plugins/gea/members.js +221 -0
  259. package/dist/plugins/gea/plugin.d.ts +22 -0
  260. package/dist/plugins/gea/plugin.js +307 -0
  261. package/dist/plugins/gea/prelude.d.ts +78 -0
  262. package/dist/plugins/gea/prelude.js +153 -0
  263. package/dist/plugins/gea/producer.d.ts +5 -0
  264. package/dist/plugins/gea/producer.js +52 -0
  265. package/dist/plugins/gea/reactive-slots.d.ts +49 -0
  266. package/dist/plugins/gea/reactive-slots.js +578 -0
  267. package/dist/plugins/gea/render-bridge.d.ts +6 -0
  268. package/dist/plugins/gea/render-bridge.js +281 -0
  269. package/dist/plugins/gea/slots.d.ts +15 -0
  270. package/dist/plugins/gea/slots.js +36 -0
  271. package/dist/plugins/gea/template-analysis.d.ts +151 -0
  272. package/dist/plugins/gea/template-analysis.js +346 -0
  273. package/dist/plugins/gea/user-agent-styles.d.ts +9 -0
  274. package/dist/plugins/gea/user-agent-styles.js +94 -0
  275. package/dist/plugins/installed.d.ts +19 -0
  276. package/dist/plugins/installed.js +21 -0
  277. package/dist/plugins/load.d.ts +7 -0
  278. package/dist/plugins/load.js +207 -0
  279. package/dist/plugins/model.d.ts +735 -0
  280. package/dist/plugins/model.js +47 -0
  281. package/dist/plugins/webgl/host.d.ts +77 -0
  282. package/dist/plugins/webgl/host.js +162 -0
  283. package/dist/plugins/webgl/plugin.d.ts +40 -0
  284. package/dist/plugins/webgl/plugin.js +99 -0
  285. package/dist/preflight/obligations.d.ts +206 -0
  286. package/dist/preflight/obligations.js +36 -0
  287. package/dist/preflight/report.d.ts +20 -0
  288. package/dist/preflight/report.js +61 -0
  289. package/dist/preflight/run.d.ts +39 -0
  290. package/dist/preflight/run.js +403 -0
  291. package/dist/project-preparation.d.ts +33 -0
  292. package/dist/project-preparation.js +314 -0
  293. package/dist/projection/abi.d.ts +82 -0
  294. package/dist/projection/abi.js +349 -0
  295. package/dist/projection/apply-arguments.d.ts +12 -0
  296. package/dist/projection/apply-arguments.js +20 -0
  297. package/dist/projection/bindings.d.ts +250 -0
  298. package/dist/projection/bindings.js +340 -0
  299. package/dist/projection/callee.d.ts +196 -0
  300. package/dist/projection/callee.js +444 -0
  301. package/dist/projection/class-property-presence.d.ts +28 -0
  302. package/dist/projection/class-property-presence.js +58 -0
  303. package/dist/projection/class-prototype.d.ts +5 -0
  304. package/dist/projection/class-prototype.js +23 -0
  305. package/dist/projection/class-storage.d.ts +26 -0
  306. package/dist/projection/class-storage.js +236 -0
  307. package/dist/projection/classes.d.ts +283 -0
  308. package/dist/projection/classes.js +944 -0
  309. package/dist/projection/coercions.d.ts +20 -0
  310. package/dist/projection/coercions.js +33 -0
  311. package/dist/projection/dispatch.d.ts +167 -0
  312. package/dist/projection/dispatch.js +379 -0
  313. package/dist/projection/fields.d.ts +123 -0
  314. package/dist/projection/fields.js +383 -0
  315. package/dist/projection/instance-test.d.ts +78 -0
  316. package/dist/projection/instance-test.js +156 -0
  317. package/dist/projection/slots.d.ts +146 -0
  318. package/dist/projection/slots.js +663 -0
  319. package/dist/projection/synthesized-abi.d.ts +61 -0
  320. package/dist/projection/synthesized-abi.js +94 -0
  321. package/dist/representation/array-index.d.ts +14 -0
  322. package/dist/representation/array-index.js +17 -0
  323. package/dist/representation/callable-object.d.ts +3 -0
  324. package/dist/representation/callable-object.js +6 -0
  325. package/dist/representation/collections.d.ts +84 -0
  326. package/dist/representation/collections.js +139 -0
  327. package/dist/representation/derive.d.ts +159 -0
  328. package/dist/representation/derive.js +2546 -0
  329. package/dist/representation/difference.d.ts +30 -0
  330. package/dist/representation/difference.js +240 -0
  331. package/dist/representation/field-descriptor-policy.d.ts +19 -0
  332. package/dist/representation/field-descriptor-policy.js +39 -0
  333. package/dist/representation/function-constructor.d.ts +13 -0
  334. package/dist/representation/function-constructor.js +9 -0
  335. package/dist/representation/host-abi.d.ts +32 -0
  336. package/dist/representation/host-abi.js +97 -0
  337. package/dist/representation/host-templates.d.ts +67 -0
  338. package/dist/representation/host-templates.js +94 -0
  339. package/dist/representation/intersection.d.ts +84 -0
  340. package/dist/representation/intersection.js +149 -0
  341. package/dist/representation/literal-destination.d.ts +43 -0
  342. package/dist/representation/literal-destination.js +133 -0
  343. package/dist/representation/merge.d.ts +18 -0
  344. package/dist/representation/merge.js +83 -0
  345. package/dist/representation/model.d.ts +1160 -0
  346. package/dist/representation/model.js +1019 -0
  347. package/dist/representation/numeric-index.d.ts +13 -0
  348. package/dist/representation/numeric-index.js +29 -0
  349. package/dist/representation/object-shape.d.ts +109 -0
  350. package/dist/representation/object-shape.js +123 -0
  351. package/dist/representation/optional.d.ts +12 -0
  352. package/dist/representation/optional.js +87 -0
  353. package/dist/representation/plan.d.ts +60 -0
  354. package/dist/representation/plan.js +78 -0
  355. package/dist/representation/policies.d.ts +589 -0
  356. package/dist/representation/policies.js +107 -0
  357. package/dist/representation/primitive-domain.d.ts +1 -0
  358. package/dist/representation/primitive-domain.js +1 -0
  359. package/dist/representation/primitives.d.ts +44 -0
  360. package/dist/representation/primitives.js +78 -0
  361. package/dist/representation/publish.d.ts +49 -0
  362. package/dist/representation/publish.js +648 -0
  363. package/dist/representation/record-fields.d.ts +96 -0
  364. package/dist/representation/record-fields.js +116 -0
  365. package/dist/representation/template-object.d.ts +11 -0
  366. package/dist/representation/template-object.js +26 -0
  367. package/dist/representation/union.d.ts +30 -0
  368. package/dist/representation/union.js +324 -0
  369. package/dist/representation/value-records.d.ts +3 -0
  370. package/dist/representation/value-records.js +307 -0
  371. package/dist/representation/verify.d.ts +17 -0
  372. package/dist/representation/verify.js +221 -0
  373. package/dist/semantics/alias-this-field-declaration-transform.d.ts +4 -0
  374. package/dist/semantics/alias-this-field-declaration-transform.js +207 -0
  375. package/dist/semantics/ambient-type-realization-transform.d.ts +62 -0
  376. package/dist/semantics/ambient-type-realization-transform.js +168 -0
  377. package/dist/semantics/ambient.d.ts +24 -0
  378. package/dist/semantics/ambient.js +119 -0
  379. package/dist/semantics/borrowed-builtin-call-bind-source-transform.d.ts +4 -0
  380. package/dist/semantics/borrowed-builtin-call-bind-source-transform.js +341 -0
  381. package/dist/semantics/callable-origins.d.ts +46 -0
  382. package/dist/semantics/callable-origins.js +354 -0
  383. package/dist/semantics/class-alias.d.ts +7 -0
  384. package/dist/semantics/class-alias.js +37 -0
  385. package/dist/semantics/class-heritage.d.ts +34 -0
  386. package/dist/semantics/class-heritage.js +104 -0
  387. package/dist/semantics/commonjs-wrapper.d.ts +69 -0
  388. package/dist/semantics/commonjs-wrapper.js +231 -0
  389. package/dist/semantics/constructor-slot-subclasses.d.ts +28 -0
  390. package/dist/semantics/constructor-slot-subclasses.js +112 -0
  391. package/dist/semantics/declaration-overlay-transform.d.ts +35 -0
  392. package/dist/semantics/declaration-overlay-transform.js +2157 -0
  393. package/dist/semantics/define-property-source-transform.d.ts +4 -0
  394. package/dist/semantics/define-property-source-transform.js +437 -0
  395. package/dist/semantics/diagnostic-source-preparation.d.ts +24 -0
  396. package/dist/semantics/diagnostic-source-preparation.js +82 -0
  397. package/dist/semantics/documentation-ranges.d.ts +22 -0
  398. package/dist/semantics/documentation-ranges.js +36 -0
  399. package/dist/semantics/dynamic-fallback.d.ts +86 -0
  400. package/dist/semantics/dynamic-fallback.js +249 -0
  401. package/dist/semantics/frontend-timing.d.ts +6 -0
  402. package/dist/semantics/frontend-timing.js +35 -0
  403. package/dist/semantics/frontend.d.ts +504 -0
  404. package/dist/semantics/frontend.js +1157 -0
  405. package/dist/semantics/host-declaration-provenance.d.ts +11 -0
  406. package/dist/semantics/host-declaration-provenance.js +18 -0
  407. package/dist/semantics/host-methods.d.ts +24 -0
  408. package/dist/semantics/host-methods.js +74 -0
  409. package/dist/semantics/host-protocols.d.ts +429 -0
  410. package/dist/semantics/host-protocols.js +1501 -0
  411. package/dist/semantics/inherited-accessor.d.ts +7 -0
  412. package/dist/semantics/inherited-accessor.js +48 -0
  413. package/dist/semantics/interface-families.d.ts +70 -0
  414. package/dist/semantics/interface-families.js +180 -0
  415. package/dist/semantics/interface-implementors.d.ts +53 -0
  416. package/dist/semantics/interface-implementors.js +87 -0
  417. package/dist/semantics/jsdoc-namepath-transform.d.ts +4 -0
  418. package/dist/semantics/jsdoc-namepath-transform.js +85 -0
  419. package/dist/semantics/model/coverage.d.ts +68 -0
  420. package/dist/semantics/model/coverage.js +73 -0
  421. package/dist/semantics/model/edges.d.ts +103 -0
  422. package/dist/semantics/model/edges.js +20 -0
  423. package/dist/semantics/model/graph.d.ts +55 -0
  424. package/dist/semantics/model/graph.js +129 -0
  425. package/dist/semantics/model/operands.d.ts +159 -0
  426. package/dist/semantics/model/operands.js +26 -0
  427. package/dist/semantics/model/operations.d.ts +496 -0
  428. package/dist/semantics/model/operations.js +2 -0
  429. package/dist/semantics/model/primitive-domain.d.ts +26 -0
  430. package/dist/semantics/model/primitive-domain.js +38 -0
  431. package/dist/semantics/model/selected-signature.d.ts +261 -0
  432. package/dist/semantics/model/selected-signature.js +55 -0
  433. package/dist/semantics/model/structural-type-table.d.ts +93 -0
  434. package/dist/semantics/model/structural-type-table.js +237 -0
  435. package/dist/semantics/model/structural-types.d.ts +367 -0
  436. package/dist/semantics/model/structural-types.js +200 -0
  437. package/dist/semantics/module-resolution.d.ts +23 -0
  438. package/dist/semantics/module-resolution.js +227 -0
  439. package/dist/semantics/new-callee-class-tag-source-transform.d.ts +4 -0
  440. package/dist/semantics/new-callee-class-tag-source-transform.js +64 -0
  441. package/dist/semantics/node-project.d.ts +13 -0
  442. package/dist/semantics/node-project.js +107 -0
  443. package/dist/semantics/node-source-hooks.d.ts +1 -0
  444. package/dist/semantics/node-source-hooks.js +63 -0
  445. package/dist/semantics/normalize/absent-globals.d.ts +143 -0
  446. package/dist/semantics/normalize/absent-globals.js +191 -0
  447. package/dist/semantics/normalize/arguments-objects.d.ts +43 -0
  448. package/dist/semantics/normalize/arguments-objects.js +60 -0
  449. package/dist/semantics/normalize/asserted-arm-absence.d.ts +28 -0
  450. package/dist/semantics/normalize/asserted-arm-absence.js +61 -0
  451. package/dist/semantics/normalize/assignment-patterns.d.ts +70 -0
  452. package/dist/semantics/normalize/assignment-patterns.js +147 -0
  453. package/dist/semantics/normalize/bag-absence.d.ts +8 -0
  454. package/dist/semantics/normalize/bag-absence.js +42 -0
  455. package/dist/semantics/normalize/binding-fixpoint.d.ts +36 -0
  456. package/dist/semantics/normalize/binding-fixpoint.js +140 -0
  457. package/dist/semantics/normalize/callback-parameter-contracts.d.ts +16 -0
  458. package/dist/semantics/normalize/callback-parameter-contracts.js +91 -0
  459. package/dist/semantics/normalize/cells/agreement.d.ts +46 -0
  460. package/dist/semantics/normalize/cells/agreement.js +34 -0
  461. package/dist/semantics/normalize/cells/candidates.d.ts +17 -0
  462. package/dist/semantics/normalize/cells/candidates.js +35 -0
  463. package/dist/semantics/normalize/cells/facts.d.ts +19 -0
  464. package/dist/semantics/normalize/cells/facts.js +90 -0
  465. package/dist/semantics/normalize/cells/index.d.ts +10 -0
  466. package/dist/semantics/normalize/cells/index.js +6 -0
  467. package/dist/semantics/normalize/cells/model.d.ts +98 -0
  468. package/dist/semantics/normalize/cells/model.js +2 -0
  469. package/dist/semantics/normalize/cells/policies/bag.d.ts +44 -0
  470. package/dist/semantics/normalize/cells/policies/bag.js +114 -0
  471. package/dist/semantics/normalize/cells/policies/collection.d.ts +42 -0
  472. package/dist/semantics/normalize/cells/policies/collection.js +218 -0
  473. package/dist/semantics/normalize/cells/policies/field.d.ts +28 -0
  474. package/dist/semantics/normalize/cells/policies/field.js +40 -0
  475. package/dist/semantics/normalize/cells/policies/index.d.ts +49 -0
  476. package/dist/semantics/normalize/cells/policies/index.js +58 -0
  477. package/dist/semantics/normalize/cells/policies/local.d.ts +18 -0
  478. package/dist/semantics/normalize/cells/policies/local.js +37 -0
  479. package/dist/semantics/normalize/cells/policies/parameter.d.ts +28 -0
  480. package/dist/semantics/normalize/cells/policies/parameter.js +39 -0
  481. package/dist/semantics/normalize/cells/policies/return.d.ts +26 -0
  482. package/dist/semantics/normalize/cells/policies/return.js +45 -0
  483. package/dist/semantics/normalize/cells/policies/shared.d.ts +33 -0
  484. package/dist/semantics/normalize/cells/policies/shared.js +45 -0
  485. package/dist/semantics/normalize/cells/policy.d.ts +72 -0
  486. package/dist/semantics/normalize/cells/policy.js +18 -0
  487. package/dist/semantics/normalize/cells/registry.d.ts +14 -0
  488. package/dist/semantics/normalize/cells/registry.js +17 -0
  489. package/dist/semantics/normalize/census-refusal.d.ts +62 -0
  490. package/dist/semantics/normalize/census-refusal.js +27 -0
  491. package/dist/semantics/normalize/census.d.ts +109 -0
  492. package/dist/semantics/normalize/census.js +667 -0
  493. package/dist/semantics/normalize/collection-bindings.d.ts +278 -0
  494. package/dist/semantics/normalize/collection-bindings.js +677 -0
  495. package/dist/semantics/normalize/commonjs-module-record.d.ts +21 -0
  496. package/dist/semantics/normalize/commonjs-module-record.js +289 -0
  497. package/dist/semantics/normalize/commonjs-require.d.ts +13 -0
  498. package/dist/semantics/normalize/commonjs-require.js +1527 -0
  499. package/dist/semantics/normalize/contribution.d.ts +63 -0
  500. package/dist/semantics/normalize/contribution.js +172 -0
  501. package/dist/semantics/normalize/dead-typeof-guards.d.ts +64 -0
  502. package/dist/semantics/normalize/dead-typeof-guards.js +152 -0
  503. package/dist/semantics/normalize/deferred-intrinsic-protocols.d.ts +57 -0
  504. package/dist/semantics/normalize/deferred-intrinsic-protocols.js +109 -0
  505. package/dist/semantics/normalize/derived-expression-type.d.ts +1070 -0
  506. package/dist/semantics/normalize/derived-expression-type.js +3463 -0
  507. package/dist/semantics/normalize/evaluation-order.d.ts +16 -0
  508. package/dist/semantics/normalize/evaluation-order.js +37 -0
  509. package/dist/semantics/normalize/field-bindings.d.ts +167 -0
  510. package/dist/semantics/normalize/field-bindings.js +1125 -0
  511. package/dist/semantics/normalize/flow/array-element-continuation.d.ts +27 -0
  512. package/dist/semantics/normalize/flow/array-element-continuation.js +1452 -0
  513. package/dist/semantics/normalize/flow/callable-array-origins.d.ts +42 -0
  514. package/dist/semantics/normalize/flow/callable-array-origins.js +318 -0
  515. package/dist/semantics/normalize/flow/callable-completions.d.ts +45 -0
  516. package/dist/semantics/normalize/flow/callable-completions.js +82 -0
  517. package/dist/semantics/normalize/flow/callable-reach.d.ts +237 -0
  518. package/dist/semantics/normalize/flow/callable-reach.js +7174 -0
  519. package/dist/semantics/normalize/flow/class-family-member-read.d.ts +16 -0
  520. package/dist/semantics/normalize/flow/class-family-member-read.js +992 -0
  521. package/dist/semantics/normalize/flow/collection-value-continuation.d.ts +21 -0
  522. package/dist/semantics/normalize/flow/collection-value-continuation.js +192 -0
  523. package/dist/semantics/normalize/flow/component-solver.d.ts +199 -0
  524. package/dist/semantics/normalize/flow/component-solver.js +587 -0
  525. package/dist/semantics/normalize/flow/computed-key-set.d.ts +84 -0
  526. package/dist/semantics/normalize/flow/computed-key-set.js +660 -0
  527. package/dist/semantics/normalize/flow/export-importers.d.ts +24 -0
  528. package/dist/semantics/normalize/flow/export-importers.js +269 -0
  529. package/dist/semantics/normalize/flow/host-text-sink.d.ts +25 -0
  530. package/dist/semantics/normalize/flow/host-text-sink.js +87 -0
  531. package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.d.ts +84 -0
  532. package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.js +180 -0
  533. package/dist/semantics/normalize/flow/intrinsic-data-definition.d.ts +35 -0
  534. package/dist/semantics/normalize/flow/intrinsic-data-definition.js +140 -0
  535. package/dist/semantics/normalize/flow/invocation-facts.d.ts +98 -0
  536. package/dist/semantics/normalize/flow/invocation-facts.js +257 -0
  537. package/dist/semantics/normalize/flow/member-call-forwarding.d.ts +122 -0
  538. package/dist/semantics/normalize/flow/member-call-forwarding.js +835 -0
  539. package/dist/semantics/normalize/flow/model.d.ts +357 -0
  540. package/dist/semantics/normalize/flow/model.js +177 -0
  541. package/dist/semantics/normalize/flow/native-collection-protocol.d.ts +24 -0
  542. package/dist/semantics/normalize/flow/native-collection-protocol.js +252 -0
  543. package/dist/semantics/normalize/flow/node-path-token.d.ts +3 -0
  544. package/dist/semantics/normalize/flow/node-path-token.js +53 -0
  545. package/dist/semantics/normalize/flow/object-binding-continuation.d.ts +11 -0
  546. package/dist/semantics/normalize/flow/object-binding-continuation.js +42 -0
  547. package/dist/semantics/normalize/flow/origin-authority.d.ts +56 -0
  548. package/dist/semantics/normalize/flow/origin-authority.js +2 -0
  549. package/dist/semantics/normalize/flow/owned-class-receivers.d.ts +35 -0
  550. package/dist/semantics/normalize/flow/owned-class-receivers.js +191 -0
  551. package/dist/semantics/normalize/flow/parameter-values.d.ts +27 -0
  552. package/dist/semantics/normalize/flow/parameter-values.js +251 -0
  553. package/dist/semantics/normalize/flow/proof-hypotheses.d.ts +66 -0
  554. package/dist/semantics/normalize/flow/proof-hypotheses.js +162 -0
  555. package/dist/semantics/normalize/flow/record-alias-closure.d.ts +27 -0
  556. package/dist/semantics/normalize/flow/record-alias-closure.js +298 -0
  557. package/dist/semantics/normalize/flow/seeded-origins.d.ts +43 -0
  558. package/dist/semantics/normalize/flow/seeded-origins.js +54 -0
  559. package/dist/semantics/normalize/flow/source-class-data.d.ts +132 -0
  560. package/dist/semantics/normalize/flow/source-class-data.js +838 -0
  561. package/dist/semantics/normalize/flow/source-class-instanceof.d.ts +13 -0
  562. package/dist/semantics/normalize/flow/source-class-instanceof.js +37 -0
  563. package/dist/semantics/normalize/flow/source-class-static-data.d.ts +16 -0
  564. package/dist/semantics/normalize/flow/source-class-static-data.js +47 -0
  565. package/dist/semantics/normalize/flow/source-construction-frames.d.ts +12 -0
  566. package/dist/semantics/normalize/flow/source-construction-frames.js +118 -0
  567. package/dist/semantics/normalize/flow/source-invocation-frame-layout.d.ts +34 -0
  568. package/dist/semantics/normalize/flow/source-invocation-frame-layout.js +78 -0
  569. package/dist/semantics/normalize/flow/source-invocation-receiver.d.ts +37 -0
  570. package/dist/semantics/normalize/flow/source-invocation-receiver.js +95 -0
  571. package/dist/semantics/normalize/flow/source-prototype-method-identity.d.ts +23 -0
  572. package/dist/semantics/normalize/flow/source-prototype-method-identity.js +81 -0
  573. package/dist/semantics/normalize/flow/source-record-data.d.ts +29 -0
  574. package/dist/semantics/normalize/flow/source-record-data.js +626 -0
  575. package/dist/semantics/normalize/flow/source-value-session.d.ts +77 -0
  576. package/dist/semantics/normalize/flow/source-value-session.js +3089 -0
  577. package/dist/semantics/normalize/flow/targets.d.ts +118 -0
  578. package/dist/semantics/normalize/flow/targets.js +405 -0
  579. package/dist/semantics/normalize/flow/value-flow.d.ts +36 -0
  580. package/dist/semantics/normalize/flow/value-flow.js +823 -0
  581. package/dist/semantics/normalize/flow/value-provenance.d.ts +31 -0
  582. package/dist/semantics/normalize/flow/value-provenance.js +112 -0
  583. package/dist/semantics/normalize/gating.d.ts +51 -0
  584. package/dist/semantics/normalize/gating.js +560 -0
  585. package/dist/semantics/normalize/generic-function-choice.d.ts +31 -0
  586. package/dist/semantics/normalize/generic-function-choice.js +115 -0
  587. package/dist/semantics/normalize/global-host-mutations.d.ts +51 -0
  588. package/dist/semantics/normalize/global-host-mutations.js +5989 -0
  589. package/dist/semantics/normalize/host-effect-contracts.d.ts +77 -0
  590. package/dist/semantics/normalize/host-effect-contracts.js +143 -0
  591. package/dist/semantics/normalize/host-mutation-computed-keys.d.ts +38 -0
  592. package/dist/semantics/normalize/host-mutation-computed-keys.js +26 -0
  593. package/dist/semantics/normalize/host-mutation-key-reader.d.ts +66 -0
  594. package/dist/semantics/normalize/host-mutation-key-reader.js +192 -0
  595. package/dist/semantics/normalize/host-mutation-keys.d.ts +114 -0
  596. package/dist/semantics/normalize/host-mutation-keys.js +183 -0
  597. package/dist/semantics/normalize/identities.d.ts +172 -0
  598. package/dist/semantics/normalize/identities.js +426 -0
  599. package/dist/semantics/normalize/implicit-arguments-tuple.d.ts +97 -0
  600. package/dist/semantics/normalize/implicit-arguments-tuple.js +197 -0
  601. package/dist/semantics/normalize/implicit-arguments.d.ts +11 -0
  602. package/dist/semantics/normalize/implicit-arguments.js +39 -0
  603. package/dist/semantics/normalize/instantiation.d.ts +73 -0
  604. package/dist/semantics/normalize/instantiation.js +399 -0
  605. package/dist/semantics/normalize/intrinsic-property-call.d.ts +18 -0
  606. package/dist/semantics/normalize/intrinsic-property-call.js +69 -0
  607. package/dist/semantics/normalize/intrinsic-prototype.d.ts +41 -0
  608. package/dist/semantics/normalize/intrinsic-prototype.js +87 -0
  609. package/dist/semantics/normalize/intrinsic-static-member.d.ts +14 -0
  610. package/dist/semantics/normalize/intrinsic-static-member.js +23 -0
  611. package/dist/semantics/normalize/jsdoc-type-names.d.ts +32 -0
  612. package/dist/semantics/normalize/jsdoc-type-names.js +512 -0
  613. package/dist/semantics/normalize/keyof.d.ts +32 -0
  614. package/dist/semantics/normalize/keyof.js +110 -0
  615. package/dist/semantics/normalize/local-bindings.d.ts +176 -0
  616. package/dist/semantics/normalize/local-bindings.js +1826 -0
  617. package/dist/semantics/normalize/logical-result-type.d.ts +16 -0
  618. package/dist/semantics/normalize/logical-result-type.js +102 -0
  619. package/dist/semantics/normalize/namespace-paths.d.ts +57 -0
  620. package/dist/semantics/normalize/namespace-paths.js +108 -0
  621. package/dist/semantics/normalize/normalize.d.ts +57 -0
  622. package/dist/semantics/normalize/normalize.js +68 -0
  623. package/dist/semantics/normalize/object-bag-bindings.d.ts +305 -0
  624. package/dist/semantics/normalize/object-bag-bindings.js +1290 -0
  625. package/dist/semantics/normalize/omitted-stated-parameter.d.ts +53 -0
  626. package/dist/semantics/normalize/omitted-stated-parameter.js +59 -0
  627. package/dist/semantics/normalize/open-type-form.d.ts +10 -0
  628. package/dist/semantics/normalize/open-type-form.js +32 -0
  629. package/dist/semantics/normalize/parameter-bindings.d.ts +361 -0
  630. package/dist/semantics/normalize/parameter-bindings.js +3339 -0
  631. package/dist/semantics/normalize/parameter-slot.d.ts +264 -0
  632. package/dist/semantics/normalize/parameter-slot.js +491 -0
  633. package/dist/semantics/normalize/physical-overload-result.d.ts +77 -0
  634. package/dist/semantics/normalize/physical-overload-result.js +99 -0
  635. package/dist/semantics/normalize/primitive-property-absence.d.ts +12 -0
  636. package/dist/semantics/normalize/primitive-property-absence.js +60 -0
  637. package/dist/semantics/normalize/producer-context.d.ts +376 -0
  638. package/dist/semantics/normalize/producer-context.js +1 -0
  639. package/dist/semantics/normalize/producers/allocations.d.ts +3 -0
  640. package/dist/semantics/normalize/producers/allocations.js +863 -0
  641. package/dist/semantics/normalize/producers/binding-kind.d.ts +37 -0
  642. package/dist/semantics/normalize/producers/binding-kind.js +36 -0
  643. package/dist/semantics/normalize/producers/bindings.d.ts +85 -0
  644. package/dist/semantics/normalize/producers/bindings.js +710 -0
  645. package/dist/semantics/normalize/producers/boundary.d.ts +34 -0
  646. package/dist/semantics/normalize/producers/boundary.js +123 -0
  647. package/dist/semantics/normalize/producers/class-lifecycle.d.ts +3 -0
  648. package/dist/semantics/normalize/producers/class-lifecycle.js +902 -0
  649. package/dist/semantics/normalize/producers/computations.d.ts +3 -0
  650. package/dist/semantics/normalize/producers/computations.js +613 -0
  651. package/dist/semantics/normalize/producers/control-loops.d.ts +30 -0
  652. package/dist/semantics/normalize/producers/control-loops.js +91 -0
  653. package/dist/semantics/normalize/producers/control.d.ts +30 -0
  654. package/dist/semantics/normalize/producers/control.js +923 -0
  655. package/dist/semantics/normalize/producers/declaration-lifecycle.d.ts +3 -0
  656. package/dist/semantics/normalize/producers/declaration-lifecycle.js +390 -0
  657. package/dist/semantics/normalize/producers/destructuring.d.ts +45 -0
  658. package/dist/semantics/normalize/producers/destructuring.js +1180 -0
  659. package/dist/semantics/normalize/producers/dynamic-language.d.ts +3 -0
  660. package/dist/semantics/normalize/producers/dynamic-language.js +70 -0
  661. package/dist/semantics/normalize/producers/erasure.d.ts +51 -0
  662. package/dist/semantics/normalize/producers/erasure.js +90 -0
  663. package/dist/semantics/normalize/producers/installed.d.ts +3 -0
  664. package/dist/semantics/normalize/producers/installed.js +55 -0
  665. package/dist/semantics/normalize/producers/invocations.d.ts +35 -0
  666. package/dist/semantics/normalize/producers/invocations.js +1796 -0
  667. package/dist/semantics/normalize/producers/iteration-yield.d.ts +59 -0
  668. package/dist/semantics/normalize/producers/iteration-yield.js +235 -0
  669. package/dist/semantics/normalize/producers/jsx.d.ts +3 -0
  670. package/dist/semantics/normalize/producers/jsx.js +360 -0
  671. package/dist/semantics/normalize/producers/mint.d.ts +39 -0
  672. package/dist/semantics/normalize/producers/mint.js +44 -0
  673. package/dist/semantics/normalize/producers/nullish.d.ts +16 -0
  674. package/dist/semantics/normalize/producers/nullish.js +27 -0
  675. package/dist/semantics/normalize/producers/object-assignment.d.ts +8 -0
  676. package/dist/semantics/normalize/producers/object-assignment.js +204 -0
  677. package/dist/semantics/normalize/producers/object-tag.d.ts +9 -0
  678. package/dist/semantics/normalize/producers/object-tag.js +119 -0
  679. package/dist/semantics/normalize/producers/optional-chain.d.ts +44 -0
  680. package/dist/semantics/normalize/producers/optional-chain.js +75 -0
  681. package/dist/semantics/normalize/producers/properties.d.ts +21 -0
  682. package/dist/semantics/normalize/producers/properties.js +1053 -0
  683. package/dist/semantics/normalize/producers/protocol.d.ts +67 -0
  684. package/dist/semantics/normalize/producers/protocol.js +695 -0
  685. package/dist/semantics/normalize/producers/references.d.ts +53 -0
  686. package/dist/semantics/normalize/producers/references.js +1027 -0
  687. package/dist/semantics/normalize/producers/shared.d.ts +561 -0
  688. package/dist/semantics/normalize/producers/shared.js +1683 -0
  689. package/dist/semantics/normalize/producers/spread-arguments.d.ts +72 -0
  690. package/dist/semantics/normalize/producers/spread-arguments.js +375 -0
  691. package/dist/semantics/normalize/producers/tagged-template.d.ts +5 -0
  692. package/dist/semantics/normalize/producers/tagged-template.js +307 -0
  693. package/dist/semantics/normalize/producers/tuple-spread.d.ts +189 -0
  694. package/dist/semantics/normalize/producers/tuple-spread.js +279 -0
  695. package/dist/semantics/normalize/property-key-domain.d.ts +36 -0
  696. package/dist/semantics/normalize/property-key-domain.js +150 -0
  697. package/dist/semantics/normalize/reachability.d.ts +189 -0
  698. package/dist/semantics/normalize/reachability.js +1057 -0
  699. package/dist/semantics/normalize/reassigned-bindings.d.ts +13 -0
  700. package/dist/semantics/normalize/reassigned-bindings.js +41 -0
  701. package/dist/semantics/normalize/record-storage-families.d.ts +11 -0
  702. package/dist/semantics/normalize/record-storage-families.js +109 -0
  703. package/dist/semantics/normalize/return-bindings.d.ts +260 -0
  704. package/dist/semantics/normalize/return-bindings.js +1311 -0
  705. package/dist/semantics/normalize/return-paths.d.ts +2 -0
  706. package/dist/semantics/normalize/return-paths.js +28 -0
  707. package/dist/semantics/normalize/script-global-redefinition.d.ts +44 -0
  708. package/dist/semantics/normalize/script-global-redefinition.js +75 -0
  709. package/dist/semantics/normalize/specialization.d.ts +201 -0
  710. package/dist/semantics/normalize/specialization.js +1824 -0
  711. package/dist/semantics/normalize/structural-array-element.d.ts +176 -0
  712. package/dist/semantics/normalize/structural-array-element.js +700 -0
  713. package/dist/semantics/normalize/structural-array-read.d.ts +13 -0
  714. package/dist/semantics/normalize/structural-array-read.js +124 -0
  715. package/dist/semantics/normalize/structural-callable.d.ts +12 -0
  716. package/dist/semantics/normalize/structural-callable.js +82 -0
  717. package/dist/semantics/normalize/structural-creation-order.d.ts +32 -0
  718. package/dist/semantics/normalize/structural-creation-order.js +111 -0
  719. package/dist/semantics/normalize/structural-declarations.d.ts +395 -0
  720. package/dist/semantics/normalize/structural-declarations.js +968 -0
  721. package/dist/semantics/normalize/structural-declared-body.d.ts +25 -0
  722. package/dist/semantics/normalize/structural-declared-body.js +147 -0
  723. package/dist/semantics/normalize/structural-generics.d.ts +56 -0
  724. package/dist/semantics/normalize/structural-generics.js +120 -0
  725. package/dist/semantics/normalize/structural-indexed-access.d.ts +11 -0
  726. package/dist/semantics/normalize/structural-indexed-access.js +126 -0
  727. package/dist/semantics/normalize/structural-instantiated-member.d.ts +64 -0
  728. package/dist/semantics/normalize/structural-instantiated-member.js +407 -0
  729. package/dist/semantics/normalize/structural-joins.d.ts +44 -0
  730. package/dist/semantics/normalize/structural-joins.js +143 -0
  731. package/dist/semantics/normalize/structural-layout-relevance.d.ts +29 -0
  732. package/dist/semantics/normalize/structural-layout-relevance.js +391 -0
  733. package/dist/semantics/normalize/structural-layout-type.d.ts +11 -0
  734. package/dist/semantics/normalize/structural-layout-type.js +1468 -0
  735. package/dist/semantics/normalize/structural-leaves.d.ts +49 -0
  736. package/dist/semantics/normalize/structural-leaves.js +125 -0
  737. package/dist/semantics/normalize/structural-local-union.d.ts +13 -0
  738. package/dist/semantics/normalize/structural-local-union.js +133 -0
  739. package/dist/semantics/normalize/structural-members.d.ts +26 -0
  740. package/dist/semantics/normalize/structural-members.js +84 -0
  741. package/dist/semantics/normalize/structural-mutable-method.d.ts +15 -0
  742. package/dist/semantics/normalize/structural-mutable-method.js +109 -0
  743. package/dist/semantics/normalize/structural-parts.d.ts +131 -0
  744. package/dist/semantics/normalize/structural-parts.js +737 -0
  745. package/dist/semantics/normalize/structural-receiver.d.ts +66 -0
  746. package/dist/semantics/normalize/structural-receiver.js +551 -0
  747. package/dist/semantics/normalize/structural-rules.d.ts +112 -0
  748. package/dist/semantics/normalize/structural-rules.js +93 -0
  749. package/dist/semantics/normalize/structural-self-reference.d.ts +150 -0
  750. package/dist/semantics/normalize/structural-self-reference.js +494 -0
  751. package/dist/semantics/normalize/structural.d.ts +202 -0
  752. package/dist/semantics/normalize/structural.js +4218 -0
  753. package/dist/semantics/normalize/unreduced-type-form.d.ts +41 -0
  754. package/dist/semantics/normalize/unreduced-type-form.js +53 -0
  755. package/dist/semantics/normalize/unresolvable-names.d.ts +56 -0
  756. package/dist/semantics/normalize/unresolvable-names.js +140 -0
  757. package/dist/semantics/package-sources.d.ts +16 -0
  758. package/dist/semantics/package-sources.js +365 -0
  759. package/dist/semantics/program.d.ts +151 -0
  760. package/dist/semantics/program.js +667 -0
  761. package/dist/semantics/prototype-install-source-transform.d.ts +4 -0
  762. package/dist/semantics/prototype-install-source-transform.js +341 -0
  763. package/dist/semantics/prototype-object-class-source-transform.d.ts +4 -0
  764. package/dist/semantics/prototype-object-class-source-transform.js +525 -0
  765. package/dist/semantics/prototype-reparenting.d.ts +50 -0
  766. package/dist/semantics/prototype-reparenting.js +317 -0
  767. package/dist/semantics/stable-checker.d.ts +10 -0
  768. package/dist/semantics/stable-checker.js +148 -0
  769. package/dist/semantics/subclass-member-overlay-transform.d.ts +35 -0
  770. package/dist/semantics/subclass-member-overlay-transform.js +1418 -0
  771. package/dist/semantics/symbol-keyed-expando-source-transform.d.ts +4 -0
  772. package/dist/semantics/symbol-keyed-expando-source-transform.js +66 -0
  773. package/dist/semantics/this-constructor-source-transform.d.ts +4 -0
  774. package/dist/semantics/this-constructor-source-transform.js +122 -0
  775. package/dist/semantics/uninstantiable-classes.d.ts +22 -0
  776. package/dist/semantics/uninstantiable-classes.js +75 -0
  777. package/dist/targets/cpp/balanced-units.d.ts +3 -0
  778. package/dist/targets/cpp/balanced-units.js +58 -0
  779. package/dist/targets/cpp/borrowed-call-entry.d.ts +30 -0
  780. package/dist/targets/cpp/borrowed-call-entry.js +68 -0
  781. package/dist/targets/cpp/captures.d.ts +68 -0
  782. package/dist/targets/cpp/captures.js +269 -0
  783. package/dist/targets/cpp/class-layout.d.ts +313 -0
  784. package/dist/targets/cpp/class-layout.js +483 -0
  785. package/dist/targets/cpp/class-properties/computed-method-value.d.ts +25 -0
  786. package/dist/targets/cpp/class-properties/computed-method-value.js +22 -0
  787. package/dist/targets/cpp/class-properties/emit-class-properties.d.ts +216 -0
  788. package/dist/targets/cpp/class-properties/emit-class-properties.js +917 -0
  789. package/dist/targets/cpp/class-properties/native-prototype.d.ts +11 -0
  790. package/dist/targets/cpp/class-properties/native-prototype.js +101 -0
  791. package/dist/targets/cpp/class-ref-transport.d.ts +12 -0
  792. package/dist/targets/cpp/class-ref-transport.js +32 -0
  793. package/dist/targets/cpp/conversions.d.ts +3 -0
  794. package/dist/targets/cpp/conversions.js +2027 -0
  795. package/dist/targets/cpp/deferral-safety.d.ts +82 -0
  796. package/dist/targets/cpp/deferral-safety.js +86 -0
  797. package/dist/targets/cpp/direct-call-receivers.d.ts +37 -0
  798. package/dist/targets/cpp/direct-call-receivers.js +79 -0
  799. package/dist/targets/cpp/document.d.ts +74 -0
  800. package/dist/targets/cpp/document.js +106 -0
  801. package/dist/targets/cpp/emit-allocation.d.ts +60 -0
  802. package/dist/targets/cpp/emit-allocation.js +573 -0
  803. package/dist/targets/cpp/emit-arrays.d.ts +119 -0
  804. package/dist/targets/cpp/emit-arrays.js +1047 -0
  805. package/dist/targets/cpp/emit-binding-reference.d.ts +17 -0
  806. package/dist/targets/cpp/emit-binding-reference.js +120 -0
  807. package/dist/targets/cpp/emit-bindings.d.ts +158 -0
  808. package/dist/targets/cpp/emit-bindings.js +769 -0
  809. package/dist/targets/cpp/emit-buffers.d.ts +156 -0
  810. package/dist/targets/cpp/emit-buffers.js +573 -0
  811. package/dist/targets/cpp/emit-callable.d.ts +230 -0
  812. package/dist/targets/cpp/emit-callable.js +2154 -0
  813. package/dist/targets/cpp/emit-carrier-members.d.ts +406 -0
  814. package/dist/targets/cpp/emit-carrier-members.js +1224 -0
  815. package/dist/targets/cpp/emit-coercion.d.ts +26 -0
  816. package/dist/targets/cpp/emit-coercion.js +39 -0
  817. package/dist/targets/cpp/emit-context.d.ts +1882 -0
  818. package/dist/targets/cpp/emit-context.js +904 -0
  819. package/dist/targets/cpp/emit-dynamic-properties.d.ts +174 -0
  820. package/dist/targets/cpp/emit-dynamic-properties.js +1249 -0
  821. package/dist/targets/cpp/emit-equality.d.ts +39 -0
  822. package/dist/targets/cpp/emit-equality.js +472 -0
  823. package/dist/targets/cpp/emit-exceptions.d.ts +104 -0
  824. package/dist/targets/cpp/emit-exceptions.js +513 -0
  825. package/dist/targets/cpp/emit-field-owner.d.ts +4 -0
  826. package/dist/targets/cpp/emit-field-owner.js +27 -0
  827. package/dist/targets/cpp/emit-in.d.ts +31 -0
  828. package/dist/targets/cpp/emit-in.js +426 -0
  829. package/dist/targets/cpp/emit-instanceof.d.ts +19 -0
  830. package/dist/targets/cpp/emit-instanceof.js +601 -0
  831. package/dist/targets/cpp/emit-integers.d.ts +68 -0
  832. package/dist/targets/cpp/emit-integers.js +184 -0
  833. package/dist/targets/cpp/emit-iterator.d.ts +100 -0
  834. package/dist/targets/cpp/emit-iterator.js +1137 -0
  835. package/dist/targets/cpp/emit-json.d.ts +73 -0
  836. package/dist/targets/cpp/emit-json.js +823 -0
  837. package/dist/targets/cpp/emit-jsx.d.ts +74 -0
  838. package/dist/targets/cpp/emit-jsx.js +806 -0
  839. package/dist/targets/cpp/emit-mixed-binary.d.ts +51 -0
  840. package/dist/targets/cpp/emit-mixed-binary.js +60 -0
  841. package/dist/targets/cpp/emit-namespaces.d.ts +101 -0
  842. package/dist/targets/cpp/emit-namespaces.js +133 -0
  843. package/dist/targets/cpp/emit-narrowing.d.ts +738 -0
  844. package/dist/targets/cpp/emit-narrowing.js +3967 -0
  845. package/dist/targets/cpp/emit-native-equality.d.ts +3 -0
  846. package/dist/targets/cpp/emit-native-equality.js +14 -0
  847. package/dist/targets/cpp/emit-native-selection.d.ts +5 -0
  848. package/dist/targets/cpp/emit-native-selection.js +37 -0
  849. package/dist/targets/cpp/emit-object-tag.d.ts +4 -0
  850. package/dist/targets/cpp/emit-object-tag.js +108 -0
  851. package/dist/targets/cpp/emit-owned-record.d.ts +2 -0
  852. package/dist/targets/cpp/emit-owned-record.js +15 -0
  853. package/dist/targets/cpp/emit-presence.d.ts +78 -0
  854. package/dist/targets/cpp/emit-presence.js +376 -0
  855. package/dist/targets/cpp/emit-properties.d.ts +105 -0
  856. package/dist/targets/cpp/emit-properties.js +1640 -0
  857. package/dist/targets/cpp/emit-record-view.d.ts +20 -0
  858. package/dist/targets/cpp/emit-record-view.js +354 -0
  859. package/dist/targets/cpp/emit-return.d.ts +5 -0
  860. package/dist/targets/cpp/emit-return.js +237 -0
  861. package/dist/targets/cpp/emit-sum-widening.d.ts +10 -0
  862. package/dist/targets/cpp/emit-sum-widening.js +69 -0
  863. package/dist/targets/cpp/emit-tonumber.d.ts +38 -0
  864. package/dist/targets/cpp/emit-tonumber.js +177 -0
  865. package/dist/targets/cpp/emit-tostring.d.ts +92 -0
  866. package/dist/targets/cpp/emit-tostring.js +556 -0
  867. package/dist/targets/cpp/emit-typeof.d.ts +49 -0
  868. package/dist/targets/cpp/emit-typeof.js +317 -0
  869. package/dist/targets/cpp/emit-union-properties.d.ts +181 -0
  870. package/dist/targets/cpp/emit-union-properties.js +1281 -0
  871. package/dist/targets/cpp/emit.d.ts +45 -0
  872. package/dist/targets/cpp/emit.js +2225 -0
  873. package/dist/targets/cpp/error-types.d.ts +4 -0
  874. package/dist/targets/cpp/error-types.js +11 -0
  875. package/dist/targets/cpp/function-source-reads.d.ts +72 -0
  876. package/dist/targets/cpp/function-source-reads.js +148 -0
  877. package/dist/targets/cpp/host/atomics.d.ts +25 -0
  878. package/dist/targets/cpp/host/atomics.js +63 -0
  879. package/dist/targets/cpp/host/core-globals.d.ts +108 -0
  880. package/dist/targets/cpp/host/core-globals.js +158 -0
  881. package/dist/targets/cpp/host/dynamic-argument-members.d.ts +42 -0
  882. package/dist/targets/cpp/host/dynamic-argument-members.js +61 -0
  883. package/dist/targets/cpp/host/emit-host-arity.d.ts +139 -0
  884. package/dist/targets/cpp/host/emit-host-arity.js +232 -0
  885. package/dist/targets/cpp/host/emit-host-invoke.d.ts +91 -0
  886. package/dist/targets/cpp/host/emit-host-invoke.js +1105 -0
  887. package/dist/targets/cpp/host/emit-host-object.d.ts +55 -0
  888. package/dist/targets/cpp/host/emit-host-object.js +2206 -0
  889. package/dist/targets/cpp/host/emit-host-properties.d.ts +69 -0
  890. package/dist/targets/cpp/host/emit-host-properties.js +533 -0
  891. package/dist/targets/cpp/host/emit-host-reflect.d.ts +4 -0
  892. package/dist/targets/cpp/host/emit-host-reflect.js +180 -0
  893. package/dist/targets/cpp/host/emit-host-value.d.ts +120 -0
  894. package/dist/targets/cpp/host/emit-host-value.js +392 -0
  895. package/dist/targets/cpp/host/host-members.d.ts +505 -0
  896. package/dist/targets/cpp/host/host-members.js +819 -0
  897. package/dist/targets/cpp/host/host-method-aliases.d.ts +30 -0
  898. package/dist/targets/cpp/host/host-method-aliases.js +76 -0
  899. package/dist/targets/cpp/host/native-protocols.d.ts +47 -0
  900. package/dist/targets/cpp/host/native-protocols.js +183 -0
  901. package/dist/targets/cpp/host/object-protocol.d.ts +351 -0
  902. package/dist/targets/cpp/host/object-protocol.js +671 -0
  903. package/dist/targets/cpp/host-namespace-reads.d.ts +83 -0
  904. package/dist/targets/cpp/host-namespace-reads.js +113 -0
  905. package/dist/targets/cpp/manifest/capabilities.d.ts +39 -0
  906. package/dist/targets/cpp/manifest/capabilities.js +1484 -0
  907. package/dist/targets/cpp/manifest.d.ts +23 -0
  908. package/dist/targets/cpp/manifest.js +113 -0
  909. package/dist/targets/cpp/native-error-base.d.ts +38 -0
  910. package/dist/targets/cpp/native-error-base.js +74 -0
  911. package/dist/targets/cpp/native-narrowing-transport.d.ts +12 -0
  912. package/dist/targets/cpp/native-narrowing-transport.js +151 -0
  913. package/dist/targets/cpp/native-selection-helpers.d.ts +11 -0
  914. package/dist/targets/cpp/native-selection-helpers.js +46 -0
  915. package/dist/targets/cpp/native-symbol-keys.d.ts +8 -0
  916. package/dist/targets/cpp/native-symbol-keys.js +34 -0
  917. package/dist/targets/cpp/ownership.d.ts +43 -0
  918. package/dist/targets/cpp/ownership.js +38 -0
  919. package/dist/targets/cpp/owning-conversion-input.d.ts +14 -0
  920. package/dist/targets/cpp/owning-conversion-input.js +12 -0
  921. package/dist/targets/cpp/property-read-claims.d.ts +62 -0
  922. package/dist/targets/cpp/property-read-claims.js +23 -0
  923. package/dist/targets/cpp/property-store-claims.d.ts +62 -0
  924. package/dist/targets/cpp/property-store-claims.js +26 -0
  925. package/dist/targets/cpp/prototype/emit-prototype-array.d.ts +111 -0
  926. package/dist/targets/cpp/prototype/emit-prototype-array.js +602 -0
  927. package/dist/targets/cpp/prototype/emit-prototype-date.d.ts +133 -0
  928. package/dist/targets/cpp/prototype/emit-prototype-date.js +515 -0
  929. package/dist/targets/cpp/prototype/emit-prototype-error.d.ts +13 -0
  930. package/dist/targets/cpp/prototype/emit-prototype-error.js +54 -0
  931. package/dist/targets/cpp/prototype/emit-prototype-invoke.d.ts +34 -0
  932. package/dist/targets/cpp/prototype/emit-prototype-invoke.js +1003 -0
  933. package/dist/targets/cpp/prototype/emit-prototype-iterator.d.ts +47 -0
  934. package/dist/targets/cpp/prototype/emit-prototype-iterator.js +250 -0
  935. package/dist/targets/cpp/prototype/emit-prototype-promise.d.ts +46 -0
  936. package/dist/targets/cpp/prototype/emit-prototype-promise.js +143 -0
  937. package/dist/targets/cpp/prototype/emit-prototype-regexp.d.ts +335 -0
  938. package/dist/targets/cpp/prototype/emit-prototype-regexp.js +853 -0
  939. package/dist/targets/cpp/prototype/emit-prototype-string.d.ts +42 -0
  940. package/dist/targets/cpp/prototype/emit-prototype-string.js +252 -0
  941. package/dist/targets/cpp/prototype/prototype-method-reads.d.ts +25 -0
  942. package/dist/targets/cpp/prototype/prototype-method-reads.js +182 -0
  943. package/dist/targets/cpp/reactive-dependencies.d.ts +140 -0
  944. package/dist/targets/cpp/reactive-dependencies.js +432 -0
  945. package/dist/targets/cpp/reactive-origins.d.ts +44 -0
  946. package/dist/targets/cpp/reactive-origins.js +82 -0
  947. package/dist/targets/cpp/records.d.ts +277 -0
  948. package/dist/targets/cpp/records.js +2427 -0
  949. package/dist/targets/cpp/recursive-containers.d.ts +43 -0
  950. package/dist/targets/cpp/recursive-containers.js +144 -0
  951. package/dist/targets/cpp/regexp-types.d.ts +56 -0
  952. package/dist/targets/cpp/regexp-types.js +59 -0
  953. package/dist/targets/cpp/substrate.d.ts +125 -0
  954. package/dist/targets/cpp/substrate.js +12 -0
  955. package/dist/targets/cpp/translation-unit.d.ts +219 -0
  956. package/dist/targets/cpp/translation-unit.js +2063 -0
  957. package/dist/targets/cpp/types.d.ts +280 -0
  958. package/dist/targets/cpp/types.js +1135 -0
  959. package/dist/targets/cpp/virtual-methods.d.ts +95 -0
  960. package/dist/targets/cpp/virtual-methods.js +264 -0
  961. package/package.json +95 -0
  962. package/src/targets/cpp/runtime/gea_dynamic_proxy.h +824 -0
  963. package/src/targets/cpp/runtime/gea_eval.h +1376 -0
  964. package/src/targets/cpp/runtime/gea_native_class_prototype.h +44 -0
  965. package/src/targets/cpp/runtime/gea_runtime.h +29222 -0
  966. package/src/targets/cpp/runtime/gea_runtime_builtins.cpp +55 -0
@@ -0,0 +1,1796 @@
1
+ import ts from 'typescript';
2
+ import { intrinsicPropertyCallOf } from '../intrinsic-property-call.js';
3
+ import { contributeObjectTag } from './object-tag.js';
4
+ import { bagShapeTypeAt } from '../object-bag-bindings.js';
5
+ import { isFabricatedSignatureShape, structuralCallSignatures } from '../structural-callable.js';
6
+ import { contextualArrayConstructTypeAt, contextualCollectionTypeAt, statedCollectionTypeAt } from '../structural-array-element.js';
7
+ import { implementationSignatureOf } from '../structural-declarations.js';
8
+ import { physicalGeneratorOverloadResultAt } from '../physical-overload-result.js';
9
+ import { regionId, semanticResultId } from '../../../identity/ids.js';
10
+ import { bindingKindOf } from './binding-kind.js';
11
+ import { blocked, mintOperationId, mintResult, operand } from './mint.js';
12
+ import { calleeAwareTypeAt, objectDescriptorReturnTypeAt, resolvedCalleeSignatureType, sourceForValue, unwrapErased, valueEdgesInto } from './shared.js';
13
+ import { isShortCircuitingCall, optionalChainGuardOf, optionalCallGuardOf, presentReturnTypeOf } from './optional-chain.js';
14
+ import { buildArgumentOperands } from './spread-arguments.js';
15
+ import { contributeTaggedTemplate } from './tagged-template.js';
16
+ import { normalCompletion, pureEffects, throwingCompletion } from '../../model/operands.js';
17
+ import { genericFunctionSetMembersOf } from '../../model/structural-types.js';
18
+ import { rootSpecialization } from '../identities.js';
19
+ import { isUniqueSymbolFreshType, validateInvocationResult } from '../../model/selected-signature.js';
20
+ import { impliedPatternArrayElementAt, parameterSlotTypeOf } from '../parameter-slot.js';
21
+ import { isGlobalObjectConstructor, isStandardGlobalValue, objectAssignTargetType } from '../derived-expression-type.js';
22
+ import { transparentConstClassAliasTarget } from '../../class-alias.js';
23
+ import { scriptGlobalValueRedefinitionOf } from '../script-global-redefinition.js';
24
+ import { mentionsTypeParameter } from '../return-bindings.js';
25
+ const isFunctionLikeSourceDeclaration = (declaration) => ts.isFunctionDeclaration(declaration) ||
26
+ ts.isFunctionExpression(declaration) ||
27
+ ts.isArrowFunction(declaration) ||
28
+ ts.isMethodDeclaration(declaration) ||
29
+ ts.isConstructorDeclaration(declaration) ||
30
+ ts.isGetAccessorDeclaration(declaration) ||
31
+ ts.isSetAccessorDeclaration(declaration);
32
+ const typeParametersOf = (declaration) => {
33
+ // `JSDocSignature.typeParameters` is a different node kind (`JSDocTemplateTag`);
34
+ // a JSDoc-only signature never carries a real, checker-selectable type
35
+ // parameter declaration, so it contributes none here.
36
+ if (ts.isJSDocSignature(declaration))
37
+ return [];
38
+ return declaration.typeParameters ?? [];
39
+ };
40
+ const parameterShapeOf = (context, parameter, anchor) => {
41
+ const declaration = context.identities.declarationOfSymbol(parameter);
42
+ const isParameter = declaration !== null && ts.isParameter(declaration);
43
+ // HOLDS: this callee's OWN parameter, read the census-aware way when it has
44
+ // a real parameter node to key on -- `context.types.rawTypeAt`, the same
45
+ // raw-`ts.Type` census answer `siteReturn` below already uses for the
46
+ // return side. An unannotated JS parameter is exactly the largest single
47
+ // boxed-carrier family this compiler has (the parameter census exists to
48
+ // infer it from call sites), and unlike `returnType` there is no second
49
+ // authority downstream to disagree with: `validateInvocationResult` checks
50
+ // only `returnType` against the invocation result, never `parameters`, and
51
+ // both `type` and `slot` below are derived from this one `declared` value,
52
+ // so there is nothing for this to drift out of step with.
53
+ // The SYMBOL's own type, which for a member of an instantiated generic is
54
+ // the substituted one: `WeakMap<Texture, number>.delete`'s parameter symbol
55
+ // says `Texture`, while its declaration node in `lib.es2015.collection.d.ts`
56
+ // says `K` and always will -- one node, every instantiation in the program.
57
+ const fromSymbol = context.checker.getTypeOfSymbolAtLocation(parameter, declaration ?? anchor);
58
+ // A parameter whose DECLARATION is still open where this call's own resolved
59
+ // signature has closed it. `rawTypeAt` reads the declaration node, which is
60
+ // the right authority for the census (below) and the wrong one for an
61
+ // ambient generic's member: three's `_videoTextures.delete( texture )` and
62
+ // `_sources.has( source )` published `unresolved(type parameter K)` as the
63
+ // parameter slot while the callee carrier beside it correctly said
64
+ // `(class-ref(Texture)) -> boolean` -- two authorities over one call, and
65
+ // preflight believes the slot. Gated on the symbol having actually CLOSED
66
+ // it: a genuinely generic callee this compiler monomorphizes reads `T` at
67
+ // both, and its copy is what substitutes, so nothing there changes.
68
+ const substituted = isParameter && mentionsTypeParameter(context.types.rawTypeAt(declaration)) && !mentionsTypeParameter(fromSymbol);
69
+ const declared = isParameter && !substituted ? context.types.rawTypeAt(declaration) : fromSymbol;
70
+ const flags = {
71
+ optional: isParameter ? declaration.questionToken !== undefined : false,
72
+ rest: isParameter ? declaration.dotDotDotToken !== undefined : false,
73
+ hasInitializer: isParameter ? declaration.initializer !== undefined : false
74
+ };
75
+ // A destructured parameter the program never annotated is the array its
76
+ // call sites pass, not the tuple the checker implied from the pattern --
77
+ // the same answer `structural-parts.ts`'s `parameterOf` gives the callee's
78
+ // own slot, asked of the one function so the two cannot drift.
79
+ const impliedElement = isParameter ? impliedPatternArrayElementAt(context.checker, context.parameters, declaration) : null;
80
+ // The body, callable ABI and invocation frame all consume the same bag
81
+ // storage answer. Reading the raw checker image here reconstructs the old
82
+ // literal shape and copies away fields that the census added later.
83
+ const bag = isParameter && !substituted ? bagShapeTypeAt(context.table, context.types.typeOf, context.bags, declaration) : null;
84
+ const type = bag ??
85
+ (impliedElement
86
+ ? context.table.intern({ kind: 'array', element: context.types.typeOf(impliedElement), readonly: false, extension: [] })
87
+ : context.types.typeOf(declared));
88
+ const slot = parameterSlotTypeOf((members) => context.table.intern({ kind: 'union', members }), context.types.typeOf(context.checker.getUndefinedType()), flags, type);
89
+ return { type, slot, ...flags };
90
+ };
91
+ // `getMinArgumentCount` is checker-internal; the public answer is the count of
92
+ // leading parameters before the first optional, defaulted, or rest parameter.
93
+ /**
94
+ * The implementation signature behind a resolved overload of a SOURCE
95
+ * function or method, or `null` when the signature is not one -- an
96
+ * implementation with a body of its own, an ambient overload set, a signature
97
+ * with no declaration.
98
+ *
99
+ * Only a non-generic implementation answers here. A generic one is
100
+ * instantiated per copy, and the copy a call reaches types its parameters
101
+ * and result -- the resolved signature the checker instantiated stays the
102
+ * call's convention while the target names the implementation's copy.
103
+ */
104
+ const sourceImplementationSignatureOf = (context, signature, generic = 'non-generic-only') => {
105
+ const declaration = signature?.declaration;
106
+ if (!declaration || !(ts.isFunctionDeclaration(declaration) || ts.isMethodDeclaration(declaration)))
107
+ return null;
108
+ if (declaration.body !== undefined || declaration.getSourceFile().isDeclarationFile)
109
+ return null;
110
+ const implementation = implementationSignatureOf(context.checker, declaration);
111
+ if (!implementation)
112
+ return null;
113
+ return generic === 'generic-too' || (implementation.getTypeParameters()?.length ?? 0) === 0 ? implementation : null;
114
+ };
115
+ const minimumArityOf = (context, signature) => {
116
+ let required = 0;
117
+ for (const parameter of signature.getParameters()) {
118
+ const declaration = context.identities.declarationOfSymbol(parameter);
119
+ if (!declaration || !ts.isParameter(declaration))
120
+ break;
121
+ if (declaration.questionToken || declaration.initializer || declaration.dotDotDotToken)
122
+ break;
123
+ required += 1;
124
+ }
125
+ return required;
126
+ };
127
+ /**
128
+ * The physical parameter slots a non-generic selected signature owns.
129
+ *
130
+ * The callee representation may be unavailable or deliberately open when
131
+ * preflight runs, but that does not erase the checker's authenticated frame.
132
+ * Publishing it here lets the conversion census ask whether an argument can
133
+ * enter the slot that owns it, rather than incorrectly asking whether it can
134
+ * become the call's return value. Inferred generic instantiations are omitted:
135
+ * the public checker API does not expose their mapper, and guessing it from an
136
+ * argument would create a second authority over the slot type.
137
+ */
138
+ const argumentConversionRolesOf = (selected, operands) => {
139
+ if (!selected || selected.typeArguments.kind !== 'none')
140
+ return [];
141
+ const roles = [];
142
+ for (const argument of operands) {
143
+ if (argument.role !== 'argument')
144
+ continue;
145
+ const parameter = selected.parameters[argument.ordinal];
146
+ // A rest argument is range-packed into the rest ARRAY by a different
147
+ // operation. Its element target is not the parameter slot itself, so this
148
+ // operation must not claim one it does not own.
149
+ if (!parameter || parameter.rest)
150
+ continue;
151
+ roles.push({ role: 'argument', ordinal: argument.ordinal, owner: 'parameter-slot', type: parameter.slot });
152
+ }
153
+ return roles;
154
+ };
155
+ const buildSelectedSignature = (context, node, signature) => {
156
+ const declaration = signature.declaration;
157
+ // No declaration node (the implicit constructor of a class with no written
158
+ // one, chiefly) means no `DeclarationId` can be named without fabricating
159
+ // one. `null` is the honest answer, matching an unresolved call.
160
+ if (!declaration)
161
+ return null;
162
+ const declarationId = context.identities.declarationIdOf(declaration);
163
+ const provenance = declaration.getSourceFile().isDeclarationFile ? 'ambient' : 'source';
164
+ // STATED, not held: a `this` parameter is either written out explicitly
165
+ // (`function f(this: Foo)`, read at its own node) or wholly implicit, with
166
+ // no call-site argument ever supplying it for a census to infer from --
167
+ // unlike an ordinary parameter, nothing here is a program binding the
168
+ // parameter census's call-site evidence could improve on.
169
+ const thisParameterSymbol = signature.thisParameter;
170
+ const thisParameter = thisParameterSymbol
171
+ ? context.types.typeOf(context.checker.getTypeOfSymbolAtLocation(thisParameterSymbol, thisParameterSymbol.valueDeclaration ?? declaration))
172
+ : null;
173
+ const parameters = signature.getParameters().map((parameter) => parameterShapeOf(context, parameter, declaration));
174
+ const writtenTypeArguments = node.typeArguments;
175
+ const typeParameters = typeParametersOf(declaration);
176
+ const typeArguments = writtenTypeArguments && writtenTypeArguments.length > 0
177
+ ? {
178
+ kind: 'explicit',
179
+ arguments: writtenTypeArguments.flatMap((argumentNode, index) => {
180
+ const parameterDeclaration = typeParameters[index];
181
+ if (!parameterDeclaration)
182
+ return [];
183
+ return [
184
+ {
185
+ parameter: context.identities.declarationIdOf(parameterDeclaration),
186
+ argument: context.types.typeOf(context.checker.getTypeFromTypeNode(argumentNode))
187
+ }
188
+ ];
189
+ })
190
+ }
191
+ : (signature.typeParameters?.length ?? 0) > 0
192
+ ? { kind: 'inferred', reason: 'checker-mapper-not-public' }
193
+ : { kind: 'none' };
194
+ // An async signature's checker return type really is `Promise<T>` -- this
195
+ // used to unwrap it to `T` here, in lockstep with the same reverted unwrap
196
+ // in `structural.ts`'s `signatureOf` and this file's own call-expression
197
+ // `resultType` below. `promise` is now a real, statically-typed carrier
198
+ // (`representation/derive.ts`'s `PromiseDeclarationPolicy`), so
199
+ // `SelectedSignature.returnType` stays the checker's own declared type and
200
+ // `validateInvocationResult` compares it against a `resultType` that
201
+ // agrees for the same reason (both now un-awaited). See citations.md
202
+ // finding 2.
203
+ const returnType = isShortCircuitingCall(node) ? presentReturnTypeOf(context.checker, signature) : signature.getReturnType();
204
+ // ONE authority on what this callee returns.
205
+ //
206
+ // The invocation RESULT below is `context.types.typeAt(node)`, which reaches
207
+ // the return census through the composed `ParameterBindingCensus` that
208
+ // `structural.ts` threads. This line asked the bare checker, so for every
209
+ // unannotated JS function the census resolved, the two halves of one
210
+ // operation answered differently and `validateInvocationResult` failed the
211
+ // producer closed -- correctly, because a producer really had published two
212
+ // answers for one operation. The consequence is not a reported blocker but a
213
+ // WITHHELD operation, which silently takes its citers with it: three's
214
+ // `createCanvasElement` carries `@return {HTMLCanvasElement}`, a class the
215
+ // host declares absent, while its body returns what `createElementNS`
216
+ // actually yields on this target -- and because that call is the default
217
+ // initializer of `canvas` in `const { canvas = createCanvasElement(), context
218
+ // = null, ... } = parameters`, the whole `WebGLRenderer` configuration
219
+ // pattern went with it, `context` included. Measured on the three.js app: 26 of these
220
+ // disagreements across 14 declarations, withholding 52 of its 86 withheld
221
+ // producers and 105 operations.
222
+ //
223
+ // The cure is to read the census, never to widen the guard.
224
+ // `producer-context.ts` predicted this exact failure when it declared
225
+ // `returns` and left it unconsumed -- "never both, or a call site the
226
+ // composed census resolves and a producer resolves independently could
227
+ // disagree about its own result's carrier". `frontend.ts` now populates it
228
+ // with the SAME instance the composed view answers from, so the two are one
229
+ // authority rather than two that agree by luck.
230
+ //
231
+ // The census answers for the DECLARATION, so its answer is already the
232
+ // PRESENT return: an optional chain's `undefined` is a fact about a call
233
+ // expression, not about the callee, which is the whole reason
234
+ // `presentReturnTypeOf` exists. Consulting the census first therefore needs
235
+ // no separate stripping, and the checker's answer stays the fallback for
236
+ // every declaration the census refused.
237
+ // An overload set whose one body is a GENERATOR: the overload signature
238
+ // `signature.getReturnType()` just read is a bodiless declaration, so the
239
+ // return census below has no body to read for it and would leave the
240
+ // checker's `IterableIterator<T>` standing against a call result
241
+ // `structural.ts`'s `typeAt` already publishes as the implementation's own
242
+ // `Generator<T>`. Both sides read `physicalGeneratorOverloadResultAt`, so
243
+ // this is one authority rather than a divergence to declare -- see that
244
+ // function's header for why a generator is the one overload shape where the
245
+ // body and its signatures cannot be reconciled by widening.
246
+ const physicalGeneratorReturn = physicalGeneratorOverloadResultAt(context.checker, node);
247
+ if (physicalGeneratorReturn !== null) {
248
+ return {
249
+ declaration: declarationId,
250
+ provenance,
251
+ parameters,
252
+ minimumArity: minimumArityOf(context, signature),
253
+ thisParameter,
254
+ typeArguments,
255
+ returnType: context.types.typeOf(physicalGeneratorReturn)
256
+ };
257
+ }
258
+ // `Object.getOwnPropertyDescriptor(receiver, key)` off a receiver this
259
+ // compiler already gave a real, in-program shape (a record literal, an
260
+ // array, an in-program function): the ambient declaration below has no
261
+ // body for `context.returns` to read (it is a lib.d.ts method signature),
262
+ // so nothing past this point would ever narrow its `value?: any` away from
263
+ // `dynamic` -- see `objectDescriptorReturnTypeAt`'s own header for why this
264
+ // is the one call the census-return path below can never reach on its own.
265
+ const descriptorReturn = objectDescriptorReturnTypeAt(context, node);
266
+ if (descriptorReturn !== null) {
267
+ return {
268
+ declaration: declarationId,
269
+ provenance,
270
+ parameters,
271
+ minimumArity: minimumArityOf(context, signature),
272
+ thisParameter,
273
+ typeArguments,
274
+ returnType: descriptorReturn
275
+ };
276
+ }
277
+ // `host.readFile.bind(host)`: the mapper states the bound callable's
278
+ // convention, receiver-less; the checker's own return type is the method's.
279
+ const nativeResult = context.types.boundCallResultAt(node) ?? context.types.constructResultAt(node);
280
+ if (nativeResult !== null) {
281
+ return {
282
+ declaration: declarationId,
283
+ provenance,
284
+ parameters,
285
+ minimumArity: minimumArityOf(context, signature),
286
+ thisParameter,
287
+ typeArguments,
288
+ returnType: nativeResult
289
+ };
290
+ }
291
+ const censusReturn = context.returns?.typeAt(declaration) ?? null;
292
+ const censusReturnArms = context.returns?.unionArmsAt(declaration) ?? null;
293
+ // ...and the SAME absent substitution, for the same reason.
294
+ //
295
+ // Sharing the census closed 22 of the three.js app's 26 disagreements. The four left
296
+ // were a second asymmetry between the two sides: `typeAt` ends in
297
+ // `typeOf(absentSubstitutedTypeAt(node))`, so the RESULT has every
298
+ // host-absent class collapsed to `never` before it is interned, while
299
+ // `typeOf` alone does not, so this side kept the class. Three's
300
+ // `createCanvasElement` returns `@return {HTMLCanvasElement}`, `WebGLTextures`
301
+ // constructs `new OffscreenCanvas(...)`, and the webgl plugin lists both
302
+ // absent -- so the two sides interned two different ids for one type that
303
+ // cannot exist, and the guard fired on a disagreement about nothing.
304
+ //
305
+ // Only the type-level substitution, never `absentSubstitutedTypeAt`: that
306
+ // helper also walks a property access's RECEIVER, which is a question about
307
+ // where a value came from and has no meaning for a return type.
308
+ // `context.returns` answers about the DECLARATION alone -- what a function
309
+ // BODY's own `return`s agree on -- so it has nothing to say for a
310
+ // signature whose declaration is an abstract call-signature member (an
311
+ // interface/type-alias entry, no body to read): hono's `H`, never
312
+ // instantiating its trailing generic, resolves ONE real two-parameter
313
+ // signature whose return the checker still collapses to plain `any`.
314
+ // `censusReturn` above is null there, so `returnType` stays the checker's
315
+ // raw `any` with nothing left to try -- and the INVOCATION side
316
+ // (`resultType`, below, `context.types.typeAt(node)`) may by then have a
317
+ // real answer from the same call site's own data flow (a `res = <this
318
+ // call>` write a local-binding census resolved backward from its
319
+ // enclosing function's stated return), which `validateInvocationResult`
320
+ // then refuses as a disagreement between two authorities that were never
321
+ // actually asked the same question. One last fallback closes it: the same
322
+ // call-site census, asked directly at this node, so both sides of the
323
+ // comparison below can only ever agree.
324
+ const siteReturn = censusReturn === null && (returnType.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0 ? context.types.rawTypeAt(node) : null;
325
+ const siteReturnIsUsable = siteReturn !== null && (siteReturn.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown | ts.TypeFlags.Void | ts.TypeFlags.Never)) === 0;
326
+ const substituted = context.absentGlobals.substituteAbsentType(censusReturn ?? (siteReturnIsUsable ? siteReturn : returnType));
327
+ return {
328
+ declaration: declarationId,
329
+ provenance,
330
+ parameters,
331
+ minimumArity: minimumArityOf(context, signature),
332
+ thisParameter,
333
+ typeArguments,
334
+ // A synthesized union has no public ts.Type. Its declaration and call
335
+ // result still share the return census's exact alternatives.
336
+ returnType: censusReturnArms
337
+ ? context.table.intern({
338
+ kind: 'union',
339
+ members: censusReturnArms.map((arm) => context.types.typeOf(context.absentGlobals.substituteAbsentType(arm)))
340
+ })
341
+ : context.types.typeOf(substituted)
342
+ };
343
+ };
344
+ const isNeverReassignedBinding = (context, declaration, symbol, qualified) => {
345
+ if (ts.isVariableDeclaration(declaration)) {
346
+ const list = declaration.parent;
347
+ // Reassigning a `const` is a compile error, so a program that reaches
348
+ // normalization already cannot have done it -- the grammar guarantees
349
+ // this, not a reference scan.
350
+ return ts.isVariableDeclarationList(list) && (list.flags & ts.NodeFlags.Const) !== 0;
351
+ }
352
+ if (ts.isFunctionDeclaration(declaration) || ts.isClassDeclaration(declaration)) {
353
+ // A namespace export can be written from ANY file (`ts.Debug.x = ...`),
354
+ // so a qualified name asks the program-wide question; a module-local
355
+ // binding can only be written in its own file (the census's own comment
356
+ // states why), so the bare name keeps the one-file bound.
357
+ return qualified
358
+ ? !context.reassignedBindings.isReassignedAnywhere(symbol)
359
+ : !context.reassignedBindings.isReassignedIn(declaration.getSourceFile(), symbol);
360
+ }
361
+ return false;
362
+ };
363
+ /**
364
+ * Whether a never-reassigned binding is known to hold `declaration` and
365
+ * nothing else.
366
+ *
367
+ * The checker's resolved signature names ONE declaration, but a `const`
368
+ * whose initializer chooses at runtime (`cond ? identity : setOriginalNode`)
369
+ * holds whichever arm the condition picked -- naming the resolved arm as an
370
+ * exact target would run the wrong body when the other arm was chosen. So
371
+ * a variable binding is exact only when its initializer is one hop from the
372
+ * target: the declaration itself (a function expression / arrow), or a name
373
+ * whose symbol is declared by it (any overload of it counts -- the
374
+ * implementation is what runs). A function or class declaration IS the
375
+ * target and needs no initializer.
376
+ */
377
+ const bindingHoldsExactly = (context, binding, declaration, seen = new Set()) => {
378
+ if (!ts.isVariableDeclaration(binding))
379
+ return true;
380
+ if (seen.has(binding))
381
+ return false;
382
+ seen.add(binding);
383
+ const initializer = binding.initializer ? unwrapErased(binding.initializer) : undefined;
384
+ if (!initializer)
385
+ return false;
386
+ if (initializer === declaration)
387
+ return true;
388
+ const symbol = ts.isIdentifier(initializer)
389
+ ? context.checker.getSymbolAtLocation(initializer)
390
+ : ts.isPropertyAccessExpression(initializer)
391
+ ? (context.namespacePaths.memberSymbolOf(initializer) ?? context.checker.getSymbolAtLocation(initializer.name))
392
+ : undefined;
393
+ if (!symbol)
394
+ return false;
395
+ const resolved = symbol.flags & ts.SymbolFlags.Alias ? context.checker.getAliasedSymbol(symbol) : symbol;
396
+ const declarations = resolved.getDeclarations() ?? [];
397
+ if (declarations.includes(declaration))
398
+ return true;
399
+ // `const g = f` where `f` is itself a never-reassigned binding: the same
400
+ // question one hop further, with the same grammar guarantee.
401
+ const next = context.identities.declarationOfSymbol(resolved);
402
+ return (next !== null &&
403
+ ts.isVariableDeclaration(next) &&
404
+ isNeverReassignedBinding(context, next, resolved, false) &&
405
+ bindingHoldsExactly(context, next, declaration, seen));
406
+ };
407
+ const exactFunctionTarget = (context, node, signature) => {
408
+ // A resolved overload of a source function names a body-less declaration;
409
+ // the body it runs is the implementation's, exactly as `identities.ts`'s
410
+ // `valueDeclarationOfSymbol` names it for every read of the same symbol.
411
+ const declaration = sourceImplementationSignatureOf(context, signature, 'generic-too')?.declaration ?? signature.declaration;
412
+ if (!declaration || !isFunctionLikeSourceDeclaration(declaration))
413
+ return null;
414
+ if (declaration.getSourceFile().isDeclarationFile)
415
+ return null;
416
+ if (!declaration.body)
417
+ return null;
418
+ const callee = unwrapErased(node.expression);
419
+ // A namespace-qualified callee (`Debug.assert(...)`) names its declaration
420
+ // exactly as a bare identifier does -- see `namespace-paths.ts`.
421
+ const symbol = ts.isIdentifier(callee)
422
+ ? context.checker.getSymbolAtLocation(callee)
423
+ : ts.isPropertyAccessExpression(callee)
424
+ ? (context.namespacePaths.memberSymbolOf(callee) ?? undefined)
425
+ : undefined;
426
+ if (!symbol)
427
+ return null;
428
+ const bindingDeclaration = context.identities.declarationOfSymbol(symbol);
429
+ if (!bindingDeclaration || !isNeverReassignedBinding(context, bindingDeclaration, symbol, !ts.isIdentifier(callee)))
430
+ return null;
431
+ if (!bindingHoldsExactly(context, bindingDeclaration, declaration))
432
+ return null;
433
+ const constructable = ts.isConstructorDeclaration(declaration) ||
434
+ ((ts.isFunctionDeclaration(declaration) || ts.isFunctionExpression(declaration)) &&
435
+ declaration.asteriskToken === undefined &&
436
+ (ts.getCombinedModifierFlags(declaration) & ts.ModifierFlags.Async) === 0);
437
+ return {
438
+ kind: 'exact',
439
+ target: { kind: 'function', functionId: context.identities.functionIdOf(declaration), constructable },
440
+ evidence: [
441
+ ts.isIdentifier(callee) ? 'direct-identifier-callee' : 'namespace-qualified-callee',
442
+ 'never-reassigned-binding',
443
+ 'function-like-declaration-in-source'
444
+ ]
445
+ };
446
+ };
447
+ const implicitSourceConstructorTarget = (context, node) => {
448
+ // HOLDS: what `new`'s own callee expression refers to, read the
449
+ // census-aware way (`context.types.rawTypeAt`) rather than the bare
450
+ // checker -- `new ctor()` where `ctor` is an unannotated parameter/local
451
+ // the census resolved to a real class is exactly the shape this should not
452
+ // miss. Falls back to the checker's own answer unchanged when the census
453
+ // has nothing to add, so an ordinary `new ClassName()` is unaffected.
454
+ const calleeType = context.types.rawTypeAt(node.expression);
455
+ const symbol = calleeType.getSymbol();
456
+ if (!symbol)
457
+ return null;
458
+ const declaration = context.identities.declarationOfSymbol(symbol);
459
+ if (!declaration || !ts.isClassLike(declaration))
460
+ return null;
461
+ if (declaration.members.some(ts.isConstructorDeclaration))
462
+ return null;
463
+ return {
464
+ kind: 'exact',
465
+ target: { kind: 'implicit-source-constructor', classDeclaration: context.identities.declarationIdOf(declaration) },
466
+ evidence: ['new-on-class-without-own-constructor']
467
+ };
468
+ };
469
+ /**
470
+ * A call through a CHOICE of generic source functions: the closed family of
471
+ * the copies this call instantiates, one per member, in the member order the
472
+ * set's carrier tags (`genericFunctionSetMembersOf`).
473
+ *
474
+ * The callee's value is the set's tag, not a callable (`generic-function-set`,
475
+ * representation/model.ts), so there is no frame to call through; the family
476
+ * is what `ir/lower-invocation.ts` dispatches over. Each target names the
477
+ * member it runs for, since the copies' ids do not spell the root declaration.
478
+ */
479
+ const genericSetFamilyTarget = (context, node) => {
480
+ const callee = unwrapErased(node.expression);
481
+ const shape = context.table.get(context.types.typeAt(callee)).shape;
482
+ const members = genericFunctionSetMembersOf((id) => context.table.get(id).shape, shape);
483
+ if (!members)
484
+ return null;
485
+ const copies = context.specializations.setSpecializationsAt(node, context.types.substituteTypeParameter);
486
+ if (!copies)
487
+ return null;
488
+ const targets = [];
489
+ for (const copy of copies) {
490
+ const member = context.identities.declarationIdOf(copy.declaration, rootSpecialization);
491
+ if (!members.includes(member))
492
+ return null;
493
+ const enclosing = context.identities.prefixFor(copy.declaration, context.path);
494
+ const last = enclosing[enclosing.length - 1];
495
+ const isSelfReference = last !== undefined && last.owner === copy.declaration && last.ordinal === copy.ordinal;
496
+ const copyPath = isSelfReference ? enclosing : [...enclosing, { owner: copy.declaration, ordinal: copy.ordinal }];
497
+ targets.push({
498
+ kind: 'function',
499
+ functionId: context.identities.functionIdOf(copy.declaration, copyPath),
500
+ constructable: false,
501
+ member
502
+ });
503
+ }
504
+ if (targets.length !== members.length)
505
+ return null;
506
+ return { kind: 'closed-family', targets, evidence: ['generic-function-set-callee', 'one-instantiated-copy-per-member'] };
507
+ };
508
+ const buildTarget = (context, node, signature) => {
509
+ if (ts.isNewExpression(node)) {
510
+ const implicit = implicitSourceConstructorTarget(context, node);
511
+ if (implicit)
512
+ return implicit;
513
+ }
514
+ else {
515
+ const family = genericSetFamilyTarget(context, node);
516
+ if (family)
517
+ return family;
518
+ }
519
+ if (signature) {
520
+ const exact = exactFunctionTarget(context, node, signature);
521
+ if (exact)
522
+ return exact;
523
+ }
524
+ return { kind: 'open', evidence: ['no-static-target-proof'] };
525
+ };
526
+ /**
527
+ * The constructor body a `super(...)` call sits inside, walked structurally.
528
+ *
529
+ * `super()` is only grammatically legal inside a derived class's constructor
530
+ * (an arrow function nested inside one captures the lexical `super` of the
531
+ * constructor that contains it, so walking through arrows to the nearest
532
+ * enclosing `ConstructorDeclaration` is correct rather than a shortcut). A
533
+ * class's own members always have the class itself as `.parent`, exactly as
534
+ * `class-lifecycle.ts`'s `memberContext` already assumes for every other
535
+ * member kind.
536
+ */
537
+ const enclosingConstructorOf = (node) => {
538
+ for (let current = node; current; current = current.parent) {
539
+ if (ts.isConstructorDeclaration(current))
540
+ return current;
541
+ }
542
+ return null;
543
+ };
544
+ /**
545
+ * What `super(...)` calls: a fresh read of the enclosing class's own
546
+ * `extends` name, scoped to the constructor `super()` actually runs in.
547
+ *
548
+ * `GetSuperConstructor` (the language's own definition) reads the active
549
+ * function's `[[HomeObject]]`'s prototype -- but for a *constructor*
550
+ * specifically that prototype is always the class's own extended base, fixed
551
+ * once at `ClassDefinitionEvaluation` and never re-evaluated. This compiler
552
+ * already names that base statically as `heritageExpression`
553
+ * (`class-lifecycle.ts`'s `contributeClass`), so no runtime `[[HomeObject]]`
554
+ * lookup is needed -- but citing `contributeClass`'s own `evaluate-heritage`
555
+ * citation directly would be wrong two ways at once. First, it is minted
556
+ * under the *class declaration's* caller, while `super()` executes under the
557
+ * *constructor's* -- a different IR body, and this compiler has no primitive
558
+ * for one body's IR value crossing into another's ("a value produced by a
559
+ * different owner needs capture lowering, which is not supported yet").
560
+ * Second, a heritage expression can carry side effects (`extends getBase()`),
561
+ * and the language evaluates it exactly once at class-definition time; citing
562
+ * the class's own already-computed result would ask for that value, while
563
+ * re-evaluating the expression a second time from inside the constructor
564
+ * would run those side effects again and could even name a different base.
565
+ *
566
+ * A binding read has neither problem: it is keyed by declaration identity, not
567
+ * by which body minted the read (`lowerBinding`'s `read` case loads straight
568
+ * from the named cell), and reading a name is never itself a side effect. So
569
+ * this mints its own `reference`+`binding` pair -- scoped to this call's own
570
+ * candidate and caller, exactly as `references.ts`'s own identifier handling
571
+ * would if `Base` were written again at the `super` keyword's position --
572
+ * restricted to a bare name, which is the one shape a fresh read is honestly
573
+ * equivalent to the original evaluation for. A computed or call-expression
574
+ * heritage stays refused: this compiler has no home-object primitive to
575
+ * answer it another way.
576
+ */
577
+ const superConstructorRead = (context, candidate, node) => {
578
+ const enclosingConstructor = enclosingConstructorOf(node);
579
+ const classNode = enclosingConstructor?.parent;
580
+ if (!enclosingConstructor || !classNode || !ts.isClassLike(classNode))
581
+ return null;
582
+ const heritageExpression = classNode.heritageClauses?.find((clause) => clause.token === ts.SyntaxKind.ExtendsKeyword)?.types[0]
583
+ ?.expression;
584
+ if (!heritageExpression || !ts.isIdentifier(heritageExpression))
585
+ return null;
586
+ const heritageValue = transparentConstClassAliasTarget(context.checker, heritageExpression) ?? heritageExpression;
587
+ const symbol = context.checker.getSymbolAtLocation(heritageValue);
588
+ if (!symbol)
589
+ return null;
590
+ const declaration = context.identities.symbolDeclarationId(symbol, heritageValue);
591
+ if (!declaration)
592
+ return null;
593
+ const declarationNode = context.identities.declarationOfSymbol(symbol);
594
+ const { mutable, temporalDeadZone } = declarationNode ? bindingKindOf(declarationNode) : { mutable: true, temporalDeadZone: false };
595
+ const type = context.types.typeAt(heritageValue);
596
+ const referenceId = mintOperationId(context.ordinals, candidate.id, 'reference');
597
+ const reference = {
598
+ id: referenceId,
599
+ family: 'reference',
600
+ form: 'identifier',
601
+ strict: ts.isExternalModule(heritageValue.getSourceFile()),
602
+ unresolvableThrows: false,
603
+ hasNoCell: false,
604
+ caller: candidate.caller,
605
+ operands: [],
606
+ results: [mintResult(referenceId, 'reference', type)],
607
+ completion: normalCompletion,
608
+ effects: { ...pureEffects, readsMutableState: true },
609
+ evaluationOrdinal: candidate.evaluationOrdinal
610
+ };
611
+ const readId = mintOperationId(context.ordinals, candidate.id, 'binding');
612
+ const read = {
613
+ id: readId,
614
+ family: 'binding',
615
+ action: 'read',
616
+ declaration,
617
+ mutable,
618
+ temporalDeadZone,
619
+ caller: candidate.caller,
620
+ operands: [
621
+ operand('reference', 0, { kind: 'result', result: semanticResultId(referenceId, 'reference') }, type, { kind: 'provenance' })
622
+ ],
623
+ results: [mintResult(readId, 'value', type)],
624
+ completion: temporalDeadZone ? throwingCompletion : normalCompletion,
625
+ effects: { ...pureEffects, readsMutableState: true },
626
+ evaluationOrdinal: candidate.evaluationOrdinal
627
+ };
628
+ return {
629
+ source: { kind: 'result', result: semanticResultId(readId, 'value') },
630
+ operations: [reference, read],
631
+ edges: [{ kind: 'value', result: semanticResultId(referenceId, 'reference'), to: readId, role: 'reference', ordinal: 0 }]
632
+ };
633
+ };
634
+ /**
635
+ * The `as T`/`<T>x` assertion `node` is the direct operand of, seeing past
636
+ * parentheses the same way `erasure.ts`'s `enclosingCallIfCallee` sees past
637
+ * every erasable wrapper -- but stopping at exactly `as`/`<T>`, unlike that
638
+ * function's fuller list: `satisfies` and `!` are checked WITHOUT changing
639
+ * the expression's own type, so `JSON.parse(text) satisfies Item` and
640
+ * `JSON.parse(text)!` are not a caller stating a DIFFERENT type for this
641
+ * call's own result the way `as Item`/`<Item>JSON.parse(text)` are.
642
+ */
643
+ const enclosingTypeAssertion = (node) => {
644
+ let current = node;
645
+ let parent = current.parent;
646
+ while (parent !== undefined && ts.isParenthesizedExpression(parent) && parent.expression === current) {
647
+ current = parent;
648
+ parent = current.parent;
649
+ }
650
+ if (parent === undefined)
651
+ return null;
652
+ if ((ts.isAsExpression(parent) || ts.isTypeAssertionExpression(parent)) && parent.expression === current)
653
+ return parent;
654
+ return null;
655
+ };
656
+ /**
657
+ * `JSON.parse(text) as T`'s call-site override.
658
+ *
659
+ * `JSON.parse`'s own declared signature returns `any` (`lib.es5.d.ts`), so
660
+ * `context.types.typeAt(node)` -- the call expression's OWN published type,
661
+ * independent of any enclosing assertion -- always selects
662
+ * `dynamic(declared-any-never-narrowed)` for it, while a SIBLING producer
663
+ * elsewhere (the binding this call's result flows into) correctly derives
664
+ * the asserted type `T` for that separate SemanticResult. The two never
665
+ * conflict at any existing guard -- nothing publishes "this call's own
666
+ * result disagrees with what its caller asserts" -- so without this override
667
+ * the mismatch is invisible until emission, where it renders a
668
+ * `gea::Value`-typed call assigned into a concrete `T`-typed local: real,
669
+ * uncompilable C++ (see citations.md finding 1's certify-then-fail probe).
670
+ *
671
+ * Narrowly scoped to exactly `JSON.parse(...) as T` / `<T>JSON.parse(...)`,
672
+ * never a general "any `any`-returning call wrapped in `as T` inherits T"
673
+ * rule: for an ordinary user-defined function this compiler also renders the
674
+ * BODY of, the callee's physical ABI returns whatever THAT function's own
675
+ * return type carrier is, regardless of what a caller's assertion claims --
676
+ * overriding the call's own result there would create a genuine ABI
677
+ * mismatch between the call and the function it calls. `JSON.parse` is safe
678
+ * to special-case because this compiler ALSO renders its own implementation
679
+ * (`targets/cpp/emit-json.ts`), which is what makes it physically capable of
680
+ * returning a `T`-shaped value in the first place, not a `gea::Value` this
681
+ * would be reading a lie into.
682
+ *
683
+ * The receiver check asks the checker for the SAME two facts
684
+ * `semantics/frontend.ts`'s fully-generic `ambientHostBindings` already used
685
+ * to bind this exact declaration to protocol `'JSON'` in the first place
686
+ * (the declaration's own spelled name, and that its value declaration lives
687
+ * in a `.d.ts` file rather than this program's own source) -- not a second,
688
+ * independently-drifting spelling check, but a read of the same identity
689
+ * that binding already established, through the only lens `ProducerContext`
690
+ * exposes (it carries no `hostProtocols` map of its own; threading one in was
691
+ * evaluated and rejected as unnecessary plumbing for a single call site).
692
+ * `receiverDeclaration.getSourceFile().isDeclarationFile` is what actually
693
+ * distinguishes the real ambient global from a local `const JSON = {...}`
694
+ * shadow, which would resolve its symbol's value declaration into the
695
+ * program's OWN source file instead.
696
+ */
697
+ const jsonParseResultOverride = (context, node, calleeUnwrapped) => {
698
+ if (!ts.isPropertyAccessExpression(calleeUnwrapped) || calleeUnwrapped.name.text !== 'parse')
699
+ return null;
700
+ const assertion = enclosingTypeAssertion(node);
701
+ if (!assertion)
702
+ return null;
703
+ const receiverSymbol = context.checker.getSymbolAtLocation(calleeUnwrapped.expression);
704
+ const receiverDeclaration = receiverSymbol?.valueDeclaration;
705
+ if (!receiverSymbol || receiverSymbol.name !== 'JSON' || !receiverDeclaration || !receiverDeclaration.getSourceFile().isDeclarationFile) {
706
+ return null;
707
+ }
708
+ return context.types.typeAt(assertion);
709
+ };
710
+ /**
711
+ * `new Array(n)`'s call-site override -- the identical defect
712
+ * `jsonParseResultOverride` exists for, at a different ambient signature.
713
+ *
714
+ * `lib.es5.d.ts`'s `ArrayConstructor` declares `new (arrayLength: number):
715
+ * any[]` -- not generic, so there is no type parameter for a contextual type
716
+ * to narrow the way there would be for, say, `Array.from<T>(...)`. Every
717
+ * `new Array(n)` therefore checks as `any[]` regardless of what it is
718
+ * assigned to, and `context.types.typeAt(node)` -- this call's own published
719
+ * result, same as `JSON.parse`'s -- picks the dynamic carrier for it. The
720
+ * program almost always states its real intent right there: `const xs:
721
+ * Rgb565[] = new Array(n)` declares the element type it wants in the same
722
+ * statement. Left unread, that mismatch is invisible until emission renders
723
+ * a `gea::Value`-element array assigned into a concrete `T`-element one --
724
+ * real, uncompilable C++, `emitArrayConstruct`'s own zero-/length-argument
725
+ * form included (`targets/cpp/emit-callable.ts`).
726
+ *
727
+ * Three sources for the asserted type. The first two are read the same way
728
+ * `jsonParseResultOverride` reads `as T`: an explicit assertion
729
+ * (`new Array(n) as T[]`), and -- the shape this compiler's own corpus
730
+ * actually writes -- the type annotation of the variable or field declaration
731
+ * this construction is the direct initializer of.
732
+ *
733
+ * The third is the call's CONTEXTUAL type, restricted to a destination that
734
+ * is itself an array. The earlier reading of this override said an assignment
735
+ * (`xs = new Array(n)`) must not be consulted because, unlike a fresh
736
+ * declaration's annotation, an assignment target "already has an independent
737
+ * value flowing into it". That is true of a general expression and false of
738
+ * this one: `new Array(n)` is ECMA-262 10.4.2.1, a fresh array of n HOLES,
739
+ * which has no elements of its own for a destination's element type to
740
+ * contradict. There is no independent value here to override -- only an
741
+ * allocation whose element carrier nobody has stated, and a destination that
742
+ * states it. hono's trie router writes exactly that shape
743
+ * (`let partOffsets: number[] | null = null` filled lazily with `partOffsets =
744
+ * new Array(len)`), and the store was refused outright: two `array-object`
745
+ * carriers whose elements disagree have no conversion and may never have one
746
+ * (`targets/cpp/conversions.ts` says why -- a rebuilt array drops every later
747
+ * write through the other name).
748
+ *
749
+ * A union destination is admitted only through its SOLE array arm, which is
750
+ * what `T[] | null` is: the arm is the carrier this construction physically
751
+ * becomes, and the store into the optional is then an ordinary installed
752
+ * widening. Two array arms state nothing this could pick between, and a
753
+ * non-array destination states nothing at all, so both keep `any[]`.
754
+ *
755
+ * Safe for the identical reason `JSON.parse` is: `emitArrayConstruct` is this
756
+ * compiler's own rendering of `new Array(n)`, so it is physically capable of
757
+ * allocating a `T`-element array directly -- this is not reading a lie into a
758
+ * call whose real ABI disagrees.
759
+ */
760
+ const arrayConstructResultOverride = (context, node, calleeUnwrapped) => {
761
+ if (!ts.isIdentifier(calleeUnwrapped) || calleeUnwrapped.text !== 'Array')
762
+ return null;
763
+ const receiverSymbol = context.checker.getSymbolAtLocation(calleeUnwrapped);
764
+ const receiverDeclaration = receiverSymbol?.valueDeclaration;
765
+ if (!receiverSymbol ||
766
+ receiverSymbol.name !== 'Array' ||
767
+ !receiverDeclaration ||
768
+ !receiverDeclaration.getSourceFile().isDeclarationFile) {
769
+ return null;
770
+ }
771
+ const assertion = enclosingTypeAssertion(node);
772
+ if (assertion)
773
+ return context.types.typeAt(assertion);
774
+ let current = node;
775
+ let parent = current.parent;
776
+ while (parent !== undefined && ts.isParenthesizedExpression(parent) && parent.expression === current) {
777
+ current = parent;
778
+ parent = current.parent;
779
+ }
780
+ if (parent === undefined)
781
+ return null;
782
+ if ((ts.isVariableDeclaration(parent) || ts.isPropertyDeclaration(parent)) && parent.initializer === current && parent.type) {
783
+ return context.types.typeAt(parent.type);
784
+ }
785
+ // The contextual path is the type system's, not this override's: the node's
786
+ // own structural rule (`contextual-array-construct`) already answers it, and
787
+ // a second reading here would be a second authority over one allocation --
788
+ // the same division `statedCollectionTypeAt` already keeps below.
789
+ if (contextualArrayConstructTypeAt(context.checker, node))
790
+ return context.types.typeAt(node);
791
+ return null;
792
+ };
793
+ /**
794
+ * `Object.create(null)`'s call-site override -- the same shape
795
+ * `arrayConstructResultOverride` above answers, at a third ambient signature
796
+ * whose declared return type is `any`.
797
+ *
798
+ * `lib.es5.d.ts` declares `create(o: object | null): any`, so this call's own
799
+ * published result is `dynamic(declared-any-never-narrowed)` no matter what
800
+ * the program says it is making. `const emptyParams: Params =
801
+ * Object.create(null)` (hono's pattern router) therefore emitted a
802
+ * `gea::Value::object()` -- a runtime `DynamicObject` -- stored into a
803
+ * `gea::Ref<gea::Dictionary<std::string>>` cell through `unboxValue`, whose
804
+ * payload-type check finds two different C++ types and aborts. Not a compile
805
+ * error, not a wrong answer: a program that dies on its first statement.
806
+ *
807
+ * Safe for exactly the reason the other overrides are, and no weaker one:
808
+ * this compiler renders `Object.create`'s own implementation
809
+ * (`targets/cpp/host/emit-host-object.ts`'s `createText`), so it is
810
+ * physically capable of minting the declared carrier directly -- 20.1.2.2's
811
+ * OrdinaryObjectCreate with a null prototype and no own properties IS an
812
+ * empty `gea::Dictionary<V>` or a value-initialized record struct. A carrier
813
+ * `createText` cannot mint keeps the dynamic rendering it always had, so a
814
+ * nonsense annotation fails the same way it did before rather than reading a
815
+ * lie into the call.
816
+ *
817
+ * Only the null-prototype, one-argument form: every other form refuses at
818
+ * emission (a real prototype chain and a properties object are both features
819
+ * this backend has not installed), and a call that will refuse has no result
820
+ * carrier worth overriding.
821
+ */
822
+ export const objectCreateResultOverride = (context, node, calleeUnwrapped) => {
823
+ if (!ts.isPropertyAccessExpression(calleeUnwrapped) || calleeUnwrapped.name.text !== 'create')
824
+ return null;
825
+ const receiverSymbol = context.checker.getSymbolAtLocation(calleeUnwrapped.expression);
826
+ const receiverDeclaration = receiverSymbol?.valueDeclaration;
827
+ if (!receiverSymbol ||
828
+ receiverSymbol.name !== 'Object' ||
829
+ !receiverDeclaration ||
830
+ !receiverDeclaration.getSourceFile().isDeclarationFile) {
831
+ return null;
832
+ }
833
+ if (node.arguments.length !== 1 || node.arguments[0]?.kind !== ts.SyntaxKind.NullKeyword)
834
+ return null;
835
+ const assertion = enclosingTypeAssertion(node);
836
+ if (assertion)
837
+ return context.types.typeAt(assertion);
838
+ // Contextual typing reaches destinations an immediate parent check cannot:
839
+ // an object-literal field, an argument slot, and an indexed assignment are
840
+ // all real declarations of the carrier this fresh null-prototype object
841
+ // must have. The checker exposes that destination directly on the call.
842
+ // Accept only a concrete object shape; `any`, unions, classes and callable
843
+ // contexts keep the dynamic result and therefore cannot silently mint a
844
+ // carrier `Object.create`'s native renderer does not know how to build.
845
+ const contextual = context.checker.getContextualType(node);
846
+ if (contextual !== undefined && (contextual.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) === 0) {
847
+ const contextualType = context.types.typeOf(contextual);
848
+ let contextualShape = context.table.get(contextualType).shape;
849
+ while ((contextualShape.kind === 'declared' || contextualShape.kind === 'object-anchor') && contextualShape.body !== null) {
850
+ contextualShape = context.table.get(contextualShape.body).shape;
851
+ }
852
+ if (contextualShape.kind === 'object')
853
+ return contextualType;
854
+ }
855
+ let current = node;
856
+ let parent = current.parent;
857
+ while (parent !== undefined && ts.isParenthesizedExpression(parent) && parent.expression === current) {
858
+ current = parent;
859
+ parent = current.parent;
860
+ }
861
+ if (parent === undefined)
862
+ return null;
863
+ if ((ts.isVariableDeclaration(parent) || ts.isPropertyDeclaration(parent)) && parent.initializer === current && parent.type) {
864
+ return context.types.typeAt(parent.type);
865
+ }
866
+ return null;
867
+ };
868
+ /**
869
+ * `Object.assign(target, source)`'s call result is the target's identity.
870
+ *
871
+ * TypeScript exposes the result as `T & U` so later source code can name the
872
+ * copied keys. ECMAScript performs no conversion or allocation: it writes the
873
+ * source's own properties into `target` and returns `target`. Publishing the
874
+ * intersection as a separate physical record asks the backend to rebuild the
875
+ * object at the call and again when it flows back into a `T` slot, breaking
876
+ * identity and (for an index signature) losing the runtime key set. Publish
877
+ * the target operand's own type instead; `Object.assign`'s native renderer
878
+ * preserves the additional keys in the target's dynamic-property sidecar.
879
+ *
880
+ * Restricted to the authenticated ambient `Object.assign` form with at least
881
+ * one source, and to an object target. A primitive target needs
882
+ * ECMAScript's wrapper-object behavior, which this backend does not model and
883
+ * therefore keeps on the ordinary refused path.
884
+ */
885
+ const objectAssignTargetOverride = (context, node, _calleeUnwrapped) => {
886
+ const targetType = objectAssignTargetType(context.checker, node);
887
+ return targetType === null ? null : context.types.typeOf(targetType);
888
+ };
889
+ /**
890
+ * The seven ambient error constructors, by the name a program spells them.
891
+ *
892
+ * `AggregateError` is deliberately absent, for the reason `gea_runtime.h`
893
+ * gives: its constructor takes the errors first and the message second, so
894
+ * the `create<ErrorRecord>(message)` template every one of these renders
895
+ * through does not describe it.
896
+ */
897
+ const errorConstructorNames = new Set([
898
+ 'Error',
899
+ 'EvalError',
900
+ 'RangeError',
901
+ 'ReferenceError',
902
+ 'SyntaxError',
903
+ 'TypeError',
904
+ 'URIError'
905
+ ]);
906
+ /**
907
+ * `new RangeError(m) as RangeError & { code: string }`'s call-site override --
908
+ * the third instance of the shape `jsonParseResultOverride` and
909
+ * `arrayConstructResultOverride` above already answer, at a third ambient
910
+ * signature.
911
+ *
912
+ * `ErrorConstructor`'s declared return type is the plain `RangeError`
913
+ * interface, so this call's own published result derives the record carrying
914
+ * `name`/`message`/`stack`/`cause` -- while the binding it initializes derives
915
+ * the intersection's record, which declares `code` as well. Two structs, and
916
+ * a value of one is not a value of the other in C++: the store between them
917
+ * has no conversion, certifies clean, and is rejected by clang. `node:http`'s
918
+ * own `validateMaxListeners` is the case.
919
+ *
920
+ * Safe for the identical reason the other two are, and for no weaker one:
921
+ * this compiler renders the construction itself, and its rendering is
922
+ * `gea::host::<Ctor>::create<ErrorRecord>` -- a TEMPLATE over the struct,
923
+ * which value-initializes the record and fills `name` and `message`. So it is
924
+ * physically capable of minting the asserted shape, and the fields the
925
+ * assertion added are left exactly as an omitted property would leave them.
926
+ * A record the create template cannot fill still refuses by name at emission
927
+ * (`targets/cpp/host/emit-host-invoke.ts`'s `renderErrorCreate` checks the
928
+ * carrier it is handed), so a nonsense assertion fails closed rather than
929
+ * being read as a lie.
930
+ *
931
+ * Only an explicit assertion is read, never a declaration's annotation:
932
+ * unlike `new Array(n)`, an error construction assigned to an annotated
933
+ * declaration typechecks only when the annotation adds nothing, so there is
934
+ * no second source to consult.
935
+ */
936
+ const errorConstructResultOverride = (context, node, calleeUnwrapped) => {
937
+ if (!ts.isIdentifier(calleeUnwrapped) || !errorConstructorNames.has(calleeUnwrapped.text))
938
+ return null;
939
+ const receiverSymbol = context.checker.getSymbolAtLocation(calleeUnwrapped);
940
+ const receiverDeclaration = receiverSymbol?.valueDeclaration;
941
+ if (!receiverSymbol ||
942
+ !errorConstructorNames.has(receiverSymbol.name) ||
943
+ !receiverDeclaration ||
944
+ !receiverDeclaration.getSourceFile().isDeclarationFile) {
945
+ return null;
946
+ }
947
+ const assertion = enclosingTypeAssertion(node);
948
+ if (!assertion)
949
+ return null;
950
+ return context.types.typeAt(assertion);
951
+ };
952
+ /**
953
+ * `new Map()`/`new Set()`/`new WeakMap()`/`new WeakSet()`'s call-site override
954
+ * -- the same shape of defect `jsonParseResultOverride` and
955
+ * `arrayConstructResultOverride` above answer, at a family the checker
956
+ * defaults instead of widening: a bare allocation gives `MapConstructor`'s
957
+ * generic signature nothing to infer K/V from, so every one of these checks
958
+ * as the SAME defaulted `Map<unknown, unknown>` (or its Set/WeakMap/WeakSet
959
+ * siblings) regardless of what the program actually stores.
960
+ *
961
+ * Unlike the two overrides above, this one reads no assertion and no
962
+ * declaration annotation of its own -- `context.collections`
963
+ * (`normalize/collection-bindings.ts`'s whole-program census) already
964
+ * answered the identical question for `structural.ts`'s `typeAt`
965
+ * (`inferredCollectionTypeArgumentsAt`, `structural-array-element.ts`), which
966
+ * is what `context.types.typeAt(node)` below already reflects for this exact
967
+ * node. Asking `context.collections.typeArgumentsAt(node)` again here is not
968
+ * a second, competing derivation of the narrowed type -- it is only the GATE:
969
+ * whether this call is one `typeAt` actually narrowed, so the override (and
970
+ * the divergence it declares) fires for exactly the calls where a real
971
+ * disagreement exists, and stays silent -- exactly like the other two
972
+ * overrides do when their own source is absent -- everywhere else.
973
+ *
974
+ * No name or symbol check of its own: `collection-bindings.ts`'s own
975
+ * `CONSTRUCTOR_NAMES`/`constructorSymbols` already verify the callee resolves
976
+ * to the real ambient `Map`/`Set`/`WeakMap`/`WeakSet` before binding anything,
977
+ * so a non-null answer here is already proof of that identity -- re-deriving
978
+ * it a second time would be the same drifting-copy risk `jsonParseResultOverride`'s
979
+ * own comment warns about, not an extra safeguard.
980
+ */
981
+ const collectionConstructResultOverride = (context, node) => {
982
+ // The second gate is the position's own statement, asked by `typeAt` after
983
+ // the census -- `contextualCollectionTypeAt`'s header says when it answers.
984
+ if (!context.collections.typeArgumentsAt(node) && !contextualCollectionTypeAt(context.checker, node))
985
+ return null;
986
+ return context.types.typeAt(node);
987
+ };
988
+ /**
989
+ * `collection.get( k )`'s call-site override -- the same collection's OTHER
990
+ * end, and the one the construct override cannot reach.
991
+ *
992
+ * Narrowing the receiver's own type does nothing here: the checker types a
993
+ * prototype call's result from the callee's signature, instantiated from the
994
+ * receiver EXPRESSION, so `properties.get( renderTarget )` stays `any` no
995
+ * matter what carrier this compiler selects for `properties`.
996
+ * `structural.ts`'s `typeAt` publishes the census's `V | undefined` instead
997
+ * (`collectionMemberResultTypeAt`, `structural-array-element.ts`), and this
998
+ * exists so that answer does not have to agree with the separate,
999
+ * checker-only return type `buildSelectedSignature` derives from the resolved
1000
+ * signature object.
1001
+ *
1002
+ * Like `collectionConstructResultOverride`, this is only the GATE, never a
1003
+ * second derivation: it asks the census the same question `typeAt` asked, and
1004
+ * returns `typeAt`'s own answer unchanged. The census admits only a bare `new
1005
+ * Map()`/`new WeakMap()` -- no type arguments, no constructor argument -- and
1006
+ * only answers a receiver resolving to one it bound a value for (or left
1007
+ * `value-unresolved` with evidence a later layer can lift), so a `.get` on
1008
+ * anything else records no divergence at all.
1009
+ *
1010
+ * The last of those is deliberately one step LOOSER than `typeAt`'s own rule,
1011
+ * which also requires the bag census to agree about that evidence
1012
+ * (`boundValueTypeId`, `structural-array-element.ts`). Reproducing that test
1013
+ * here would need the type table and the bag census inside a producer that
1014
+ * has neither, and re-deriving it from a copy is precisely the drifting
1015
+ * second authority these overrides exist to avoid. The cost of the looser
1016
+ * gate is a divergence recorded for a call where the two answers happened to
1017
+ * agree anyway, which `validateInvocationResult` treats as nothing to check
1018
+ * -- never a substituted type, since the type is `typeAt`'s own either way.
1019
+ */
1020
+ const collectionMemberResultOverride = (context, node) => {
1021
+ const callee = node.expression;
1022
+ if (!ts.isPropertyAccessExpression(callee))
1023
+ return null;
1024
+ // The receiver the POSITION typed, carried to this call through a merge
1025
+ // or an assignment the checker reads dynamically -- the same gate, asked
1026
+ // of `typeAt`'s other source (`statedCollectionTypeAt`'s header).
1027
+ if (statedCollectionTypeAt(context.checker, node))
1028
+ return context.types.typeAt(node);
1029
+ const member = callee.name.text;
1030
+ if (member !== 'get' && member !== 'set' && member !== 'add')
1031
+ return null;
1032
+ const bound = context.collections.typeArgumentsForRead(callee.expression);
1033
+ if (!bound)
1034
+ return null;
1035
+ if (member === 'get' && bound.value === null && bound.valueEvidence.length === 0)
1036
+ return null;
1037
+ return context.types.typeAt(node);
1038
+ };
1039
+ /**
1040
+ * A call whose result IS an object bag this census bound.
1041
+ *
1042
+ * The last of the five overrides, and the only one whose subject is not an
1043
+ * ambient global: three's `WebGLProperties.get` returns a `{}` filled a
1044
+ * property at a time, and nothing in the source states that. The bag census
1045
+ * knows all 47 members; the resolved signature knows `any`. Neither is wrong,
1046
+ * and `bag-return-inference` is the reason that lets both stand.
1047
+ *
1048
+ * The GATE only, as with the two collection overrides above: it asks the bag
1049
+ * census the same question `structural.ts`'s `typeAt` asked
1050
+ * (`bagShapeTypeAt` -> `callResultShapeAt`) and returns `typeAt`'s own answer
1051
+ * unchanged, so there is never a second derivation to drift.
1052
+ */
1053
+ const bagResultOverride = (context, node) => {
1054
+ if (!context.bags.callResultShapeAt(node))
1055
+ return null;
1056
+ return context.types.typeAt(node);
1057
+ };
1058
+ /**
1059
+ * Whether this call is `receiver.call(...)`/`receiver.apply(...)` with a
1060
+ * RECEIVER whose own static type carries at least one call signature --
1061
+ * the exact test `flow/callable-reach.ts`'s `unwrapExplicitThisCall` makes of
1062
+ * the identical shape, asked here for the same reason: a program is free to
1063
+ * declare its own `.call`/`.apply`-named method that has nothing to do with
1064
+ * `Function.prototype.call`/`.apply`, and only an authenticated callable
1065
+ * receiver proves this is really the ambient one.
1066
+ *
1067
+ * When it is, `structural-callable.ts`'s `createStructuralCallResultResolver`
1068
+ * is already reading the receiver's OWN call signature(s) for this call's
1069
+ * published result (wired into `context.types.typeAt` by `structural.ts`'s
1070
+ * `callResultAt`), independent of -- and more precise than -- the checker's
1071
+ * own overload-resolved `signature.getReturnType()` for `.call`/`.apply`'s
1072
+ * ambient generic signature. See `InvocationResultDivergence`'s
1073
+ * `explicit-this-call-return` for why that makes the two disagree.
1074
+ */
1075
+ const isExplicitThisCallWithAuthenticatedReceiver = (context, calleeUnwrapped) => {
1076
+ if (!ts.isPropertyAccessExpression(calleeUnwrapped))
1077
+ return false;
1078
+ const name = calleeUnwrapped.name.text;
1079
+ if (name !== 'call' && name !== 'apply')
1080
+ return false;
1081
+ return (context.checker.getSignaturesOfType(context.checker.getTypeAtLocation(calleeUnwrapped.expression), ts.SignatureKind.Call).length > 0);
1082
+ };
1083
+ /** Intrinsic mutators authenticated while checker declaration identity is available. */
1084
+ const intrinsicMutationOf = (context, node, calleeUnwrapped) => {
1085
+ if (!ts.isCallExpression(node) || !ts.isPropertyAccessExpression(calleeUnwrapped))
1086
+ return null;
1087
+ const member = calleeUnwrapped.name.text;
1088
+ const owner = calleeUnwrapped.expression;
1089
+ if (isGlobalObjectConstructor(context.checker, owner, context.checker.getTypeAtLocation(owner))) {
1090
+ if (member === 'assign')
1091
+ return 'object-assign';
1092
+ if (member === 'defineProperty')
1093
+ return 'object-define-property';
1094
+ if (member === 'defineProperties')
1095
+ return 'object-define-properties';
1096
+ }
1097
+ if (member === 'set' && isStandardGlobalValue(context.checker, owner, 'Reflect'))
1098
+ return 'reflect-set';
1099
+ return null;
1100
+ };
1101
+ /**
1102
+ * `Object.defineProperty(globalThis, 'K', { value: V })` on the program's own
1103
+ * script `var K`, published as the store `K = V` -- see
1104
+ * `script-global-redefinition.ts` for why that is exactly what the call does.
1105
+ * The mutation census asks the same predicate and files no taint for it, so
1106
+ * the var keeps one representation and every read, bare or through
1107
+ * `globalThis`, reads the cell this writes.
1108
+ */
1109
+ const contributeScriptGlobalRedefinition = (context, candidate, node) => {
1110
+ const redefinition = scriptGlobalValueRedefinitionOf(context.checker, context.unresolvableNames, node);
1111
+ if (redefinition === null)
1112
+ return null;
1113
+ // The VALUE declaration: `type Response = ResponseImpl` beside
1114
+ // `var Response` merges into one symbol whose first declaration is the
1115
+ // alias, and a store to that id writes no cell at all.
1116
+ const declaration = context.identities.symbolValueDeclarationId(redefinition.symbol);
1117
+ if (!declaration)
1118
+ return null;
1119
+ const { mutable, temporalDeadZone } = bindingKindOf(redefinition.declaration);
1120
+ const value = sourceForValue(context, redefinition.value);
1121
+ const type = context.types.typeAt(redefinition.declaration.name);
1122
+ const id = mintOperationId(context.ordinals, candidate.id, 'binding');
1123
+ const operation = {
1124
+ id,
1125
+ family: 'binding',
1126
+ action: 'write',
1127
+ declaration,
1128
+ mutable,
1129
+ temporalDeadZone,
1130
+ caller: candidate.caller,
1131
+ operands: [operand('value', 0, value, type)],
1132
+ results: [mintResult(id, 'value', type)],
1133
+ completion: normalCompletion,
1134
+ effects: { ...pureEffects, writesMutableState: true },
1135
+ evaluationOrdinal: candidate.evaluationOrdinal
1136
+ };
1137
+ return {
1138
+ kind: 'operations',
1139
+ operations: [operation],
1140
+ edges: value.kind === 'result' ? [{ kind: 'value', result: value.result, to: id, role: 'value', ordinal: 0 }] : []
1141
+ };
1142
+ };
1143
+ /**
1144
+ * `Object.setPrototypeOf(C.prototype, B.prototype)` that
1145
+ * `prototype-reparenting.ts` models as `C` inheriting from `B`: a
1146
+ * class-lifecycle step of `C`, published where the call runs, citing the two
1147
+ * class values whose evaluations it links. The `.prototype` reads are the
1148
+ * program's own and stay with the property producer; the step needs the
1149
+ * class objects they were read from, because a class evaluation is what
1150
+ * carries its prototype.
1151
+ */
1152
+ const contributePrototypeReparenting = (context, candidate, node) => {
1153
+ if (!ts.isExpressionStatement(node.parent))
1154
+ return null;
1155
+ const reparenting = context.prototypeReparentings.of(node);
1156
+ const [target, parent] = node.arguments;
1157
+ if (!reparenting || !target || !parent)
1158
+ return null;
1159
+ // The prototype half names both classes through `.prototype`; the
1160
+ // constructor half names them directly. Either way the operands are this
1161
+ // call's own arguments.
1162
+ const derivedValue = ts.isPropertyAccessExpression(target) ? target.expression : target;
1163
+ const heritageValue = ts.isPropertyAccessExpression(target) && ts.isPropertyAccessExpression(parent) ? parent.expression : parent;
1164
+ const constructorSource = sourceForValue(context, derivedValue);
1165
+ const heritageSource = sourceForValue(context, heritageValue);
1166
+ const declaration = context.identities.declarationIdOf(reparenting.derived);
1167
+ const id = mintOperationId(context.ordinals, candidate.id, 'class-lifecycle');
1168
+ const operation = {
1169
+ id,
1170
+ family: 'class-lifecycle',
1171
+ event: 'reparent-prototype',
1172
+ declaration,
1173
+ classDeclaration: declaration,
1174
+ descriptor: null,
1175
+ placement: null,
1176
+ caller: candidate.caller,
1177
+ operands: [
1178
+ operand('constructor', 0, constructorSource, context.types.typeAt(derivedValue)),
1179
+ operand('heritage', 0, heritageSource, context.types.typeAt(heritageValue))
1180
+ ],
1181
+ results: [mintResult(id, 'completion', context.table.intern({ kind: 'primitive', primitive: 'void' }))],
1182
+ // The emitted step refuses a heritage value that is not exactly `B`.
1183
+ completion: throwingCompletion,
1184
+ effects: { readsMutableState: true, writesMutableState: true, allocates: false, callsUserCode: false },
1185
+ evaluationOrdinal: candidate.evaluationOrdinal
1186
+ };
1187
+ const edges = [];
1188
+ if (constructorSource.kind === 'result')
1189
+ edges.push({ kind: 'value', result: constructorSource.result, to: id, role: 'constructor', ordinal: 0 });
1190
+ if (heritageSource.kind === 'result')
1191
+ edges.push({ kind: 'value', result: heritageSource.result, to: id, role: 'heritage', ordinal: 0 });
1192
+ return { kind: 'operations', operations: [operation], edges };
1193
+ };
1194
+ export const createInvocationProducer = (context) => ({
1195
+ family: 'invocation',
1196
+ contribute: (candidate) => {
1197
+ const node = candidate.node;
1198
+ // A tagged template is a call, but not one this function's shape fits: its
1199
+ // callee is `node.tag` rather than `node.expression`, and its first
1200
+ // argument is a synthetic per-site object no source expression names. It
1201
+ // gets its own contributor rather than a set of special cases threaded
1202
+ // through every step below.
1203
+ if (ts.isTaggedTemplateExpression(node))
1204
+ return contributeTaggedTemplate(context, candidate, node);
1205
+ const objectTag = contributeObjectTag(context, candidate, node);
1206
+ if (objectTag !== null)
1207
+ return objectTag;
1208
+ if (ts.isCallExpression(node)) {
1209
+ const reparenting = contributePrototypeReparenting(context, candidate, node);
1210
+ if (reparenting !== null)
1211
+ return reparenting;
1212
+ }
1213
+ if (ts.isCallExpression(node) && intrinsicMutationOf(context, node, unwrapErased(node.expression)) === 'object-define-property') {
1214
+ const redefinition = contributeScriptGlobalRedefinition(context, candidate, node);
1215
+ if (redefinition !== null)
1216
+ return redefinition;
1217
+ }
1218
+ const args = node.arguments ?? [];
1219
+ const isOptionalChain = ts.isCallExpression(node) && ts.isOptionalChain(node);
1220
+ const rawCallee = unwrapErased(node.expression);
1221
+ // `a?.()`, `a.b?.()`, and `a?.b()` all reach this producer -- the census
1222
+ // routes every `CallExpression` to `invocation` regardless of chain shape,
1223
+ // and `properties.ts`/`references.ts` only answer the *property* half of a
1224
+ // chain. Without a guard here, `a.b?.()` (only the call itself carries
1225
+ // `?.`) would fall straight through: the callee's own read is an ordinary,
1226
+ // unblocked property access, so nothing would stop this producer from
1227
+ // calling it unconditionally -- silently running the call on a
1228
+ // possibly-nullish value instead of skipping it.
1229
+ const guardExpression = isOptionalChain ? optionalCallGuardOf(node) : null;
1230
+ if (isOptionalChain && guardExpression === null) {
1231
+ return {
1232
+ kind: 'blocked',
1233
+ blocker: blocked(candidate.id, 'invocation', 'optional chaining requires short-circuit selection semantics', 'P0')
1234
+ };
1235
+ }
1236
+ const guardSource = guardExpression ? sourceForValue(context, guardExpression) : null;
1237
+ // The guard has to be a value some operation publishes, because that result
1238
+ // is literally what the branch tests. A constant or a `this` guard is not
1239
+ // modelled, and inventing a test over something nothing published is how a
1240
+ // call ends up gated on a block that never runs.
1241
+ if (guardExpression !== null && guardSource?.kind !== 'result') {
1242
+ return {
1243
+ kind: 'blocked',
1244
+ blocker: blocked(candidate.id, 'invocation', 'an optional call short-circuits on a producible guard result; a constant, this, or super guard is not modelled', 'P0')
1245
+ };
1246
+ }
1247
+ const shortCircuit = guardExpression !== null && guardSource?.kind === 'result'
1248
+ ? { expression: guardExpression, result: guardSource.result, source: guardSource }
1249
+ : null;
1250
+ const isSuperCall = ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.SuperKeyword;
1251
+ let resultDivergence = isSuperCall ? { kind: 'super-constructor-initialization' } : { kind: 'none' };
1252
+ const operationIdentity = mintOperationId(context.ordinals, candidate.id, 'invocation');
1253
+ const operands = [];
1254
+ // CommonJS is admitted by a host-authenticated AMBIENT DECLARATION, not by
1255
+ // this producer knowing a spelling. Once admitted, the argument must be
1256
+ // static and checker-resolved: a dynamic loader is a different host
1257
+ // capability and must not accidentally become a module-record lookup.
1258
+ if (ts.isCallExpression(node) && ts.isIdentifier(rawCallee)) {
1259
+ const require = context.commonJsRequire.statusOf(rawCallee);
1260
+ if (require === 'provenance-failure') {
1261
+ return {
1262
+ kind: 'blocked',
1263
+ blocker: blocked(candidate.id, 'invocation', 'CommonJS require provenance did not resolve to the host-owned wrapper declaration', 'P0')
1264
+ };
1265
+ }
1266
+ if (require === 'possibly-reassigned') {
1267
+ return {
1268
+ kind: 'blocked',
1269
+ blocker: blocked(candidate.id, 'invocation', 'CommonJS require may have been reassigned before this call', 'P0')
1270
+ };
1271
+ }
1272
+ if (require === 'static') {
1273
+ const argument = node.arguments[0];
1274
+ if (node.arguments.length !== 1 || !argument || !ts.isStringLiteralLike(argument)) {
1275
+ return {
1276
+ kind: 'blocked',
1277
+ blocker: blocked(candidate.id, 'invocation', 'a host-authenticated CommonJS require needs exactly one static string specifier', 'P0')
1278
+ };
1279
+ }
1280
+ const targetFileName = context.runtimeModuleTargetOf(argument.text, node.getSourceFile().fileName, 'require');
1281
+ const targetFile = targetFileName === null ? null : context.sourceFileOf(targetFileName);
1282
+ if (!targetFile || targetFile.isDeclarationFile) {
1283
+ return {
1284
+ kind: 'blocked',
1285
+ blocker: blocked(candidate.id, 'invocation', 'a static CommonJS require resolved no compiled source module', 'P0')
1286
+ };
1287
+ }
1288
+ const ownerFile = node.getSourceFile();
1289
+ const owner = regionId(context.identities.nodeIdOf(ownerFile), 'module-body');
1290
+ const target = regionId(context.identities.nodeIdOf(targetFile), 'module-body');
1291
+ const nativeRecord = context.commonJsModuleRecords.requiredExportExpressionAt(node) !== null;
1292
+ // A module record is the one deliberately dynamic host boundary
1293
+ // (`publish.ts`'s `commonJsBoundaryOf`), and its structural type has to
1294
+ // say so too: in checked JavaScript the checker types `require('./m')`
1295
+ // from the target's LAST `module.exports = ...`, which for a module with
1296
+ // two writers is one of two shapes and for a partially initialized
1297
+ // cycle is a shape that does not exist yet. Only the proven record
1298
+ // keeps the checker's answer.
1299
+ const resultType = nativeRecord ? context.types.typeAt(node) : context.types.typeOf(context.checker.getAnyType());
1300
+ const operation = {
1301
+ id: operationIdentity,
1302
+ family: 'invocation',
1303
+ caller: candidate.caller,
1304
+ internalMethod: 'call',
1305
+ optionalChain: false,
1306
+ selectedSignature: null,
1307
+ resultDivergence: { kind: 'none' },
1308
+ target: { kind: 'open', evidence: ['checker-authenticated CommonJS module record'] },
1309
+ commonJsRequire: {
1310
+ owner,
1311
+ target,
1312
+ builtinModule: context.builtinModuleNameOf(argument.text),
1313
+ ...(nativeRecord ? { nativeRecord: true } : {})
1314
+ },
1315
+ operands: [],
1316
+ results: [mintResult(operationIdentity, 'value', resultType)],
1317
+ completion: throwingCompletion,
1318
+ effects: { readsMutableState: true, writesMutableState: true, allocates: false, callsUserCode: true },
1319
+ evaluationOrdinal: candidate.evaluationOrdinal
1320
+ };
1321
+ return { kind: 'operations', operations: [operation], edges: [] };
1322
+ }
1323
+ }
1324
+ // A host may return a module selected by a runtime string. A literal call
1325
+ // through that exact host declaration retains one real ModuleRecord;
1326
+ // nonliteral and unsupported names remain runtime lookups and can only
1327
+ // observe records the program already retained by other sound evidence.
1328
+ const builtinModuleArgument = ts.isCallExpression(node) && node.arguments.length === 1 ? node.arguments[0] : undefined;
1329
+ const builtinModuleLookup = ts.isCallExpression(node) &&
1330
+ builtinModuleArgument &&
1331
+ ts.isStringLiteralLike(builtinModuleArgument) &&
1332
+ (ts.isPropertyAccessExpression(rawCallee) || ts.isElementAccessExpression(rawCallee))
1333
+ ? (() => {
1334
+ const method = context.hostMethodOf?.(rawCallee);
1335
+ const builtinModule = method?.builtinModuleLookup ? context.builtinModuleNameOf(builtinModuleArgument.text) : null;
1336
+ if (builtinModule === null)
1337
+ return null;
1338
+ const source = context.builtinModuleSourceOf(builtinModule);
1339
+ const targetFile = source === null ? null : context.sourceFileOf(source);
1340
+ if (!targetFile || targetFile.isDeclarationFile) {
1341
+ return { kind: 'blocked', reason: `host builtin module "${builtinModule}" has no compiled runtime source record` };
1342
+ }
1343
+ return {
1344
+ kind: 'lookup',
1345
+ value: { target: regionId(context.identities.nodeIdOf(targetFile), 'module-body'), builtinModule }
1346
+ };
1347
+ })()
1348
+ : null;
1349
+ if (builtinModuleLookup?.kind === 'blocked') {
1350
+ return { kind: 'blocked', blocker: blocked(candidate.id, 'invocation', builtinModuleLookup.reason, 'P0') };
1351
+ }
1352
+ // Asked unconditionally, and in the SAME position it always was: this is
1353
+ // the checker's own resolved signature for the call, independent of
1354
+ // whatever `calleeType` (below) turns out to say. Keeping this call at its
1355
+ // original spot matters -- moving it around this program's tens of
1356
+ // thousands of invocations changes evaluation order for every one of
1357
+ // them, and this producer has no license to do that just to reach the one
1358
+ // override below. `ImageUtils.getDataURL` (three.js) is the concrete
1359
+ // casualty a reordered version of this fix produced: an entirely
1360
+ // unrelated static call, whose ABI flipped from `undefined` to `void` for
1361
+ // parameter 0 the moment `calleeType`'s resolution (which interns/derives
1362
+ // representation state) started running BEFORE this line instead of
1363
+ // after it. Overriding the RESULT below, rather than the ORDER here,
1364
+ // keeps every call site's evaluation identical to before except the one
1365
+ // this fix targets.
1366
+ const resolvedSignature = context.checker.getResolvedSignature(node);
1367
+ // A call resolved against one declared overload of an overloaded SOURCE
1368
+ // function runs the implementation, whose frame is the only one that
1369
+ // exists: `pad("a")` resolves `(value: string): string` and invokes
1370
+ // `(value: string, width?: number): string`. Selecting the overload named
1371
+ // a body-less declaration -- so the target was never exact -- and an ABI
1372
+ // one parameter short of the body that binds two. The implementation's
1373
+ // own signature is the call's convention.
1374
+ const implementationSignature = sourceImplementationSignatureOf(context, resolvedSignature);
1375
+ let signature = implementationSignature ?? resolvedSignature;
1376
+ let selectedSignature = signature ? buildSelectedSignature(context, node, signature) : null;
1377
+ if (implementationSignature && resolvedSignature && selectedSignature) {
1378
+ // The implementation owns the one physical parameter frame, including
1379
+ // optional/defaulted slots omitted by a declared overload. The resolved
1380
+ // overload still owns the caller-visible result: `randomBytes(size)` is
1381
+ // `Buffer`, while the shared implementation is `Buffer | void` because
1382
+ // its callback form returns nothing. Replacing both halves with the
1383
+ // implementation signature makes the invocation producer contradict
1384
+ // the checker's selected result and, worse, loses the overload's proven
1385
+ // narrowing. Keep the implementation's frame and the resolved
1386
+ // overload's result as the two independent pieces of the call ABI.
1387
+ const resolvedSelection = buildSelectedSignature(context, node, resolvedSignature);
1388
+ if (resolvedSelection)
1389
+ selectedSignature = { ...selectedSignature, returnType: resolvedSelection.returnType };
1390
+ }
1391
+ // This expression's own type carries any of *its* unbound type parameters
1392
+ // -- `arr.map`'s type still has `map`'s own `<U>` free -- but it is also
1393
+ // this exact call's callee, and the checker already substituted every one
1394
+ // of those resolving this call, so `calleeAwareTypeAt` reads that answer
1395
+ // back instead of republishing the unbound one.
1396
+ // The convention this call needs, which for `host.raf?.(cb)` is the
1397
+ // callable the guard's present branch holds -- not the `fn | undefined` the
1398
+ // callee expression evaluates to. `calleeAwareTypeAt` deliberately answers
1399
+ // the second question for that shape, so the first is asked directly.
1400
+ const calleeType = resolvedCalleeSignatureType(context, node.expression) ?? calleeAwareTypeAt(context, node.expression);
1401
+ // A mutable method's cell transports every replacement's public frame;
1402
+ // the initial implementation is only one possible body in that cell.
1403
+ const mutableMethod = context.types.mutableMethodReadTypeAt(node.expression);
1404
+ const mutableFrame = mutableMethod === null ? null : structuralCallSignatures(context.table, mutableMethod)?.[0];
1405
+ if (mutableFrame && selectedSignature) {
1406
+ selectedSignature = {
1407
+ ...selectedSignature,
1408
+ parameters: mutableFrame.parameters,
1409
+ minimumArity: mutableFrame.minimumArity,
1410
+ thisParameter: mutableFrame.thisParameter
1411
+ };
1412
+ }
1413
+ // A callee `calleeType` resolved to genuinely dynamic (a bare `primitive
1414
+ // any`/`unknown`, `resolvedCalleeSignatureType`'s own two `any`/`unknown`
1415
+ // exits) is a call the checker never meaningfully typed, and
1416
+ // `getResolvedSignature` on it (above) is TypeScript's fabricated
1417
+ // zero-parameter `anySignature` -- the SAME fiction `resolvedCalleeSignatureType`
1418
+ // exists to see through for the callee's own representation, just read
1419
+ // back here from the RAW checker API a second, disagreeing way. `gl.texImage2D(...arguments)`
1420
+ // inside three.js's `WebGLState.js` (`gl` a genuinely untyped JS
1421
+ // parameter) is the concrete case: `calleeType` correctly resolves it
1422
+ // `dynamic`, but `checker.getResolvedSignature` still hands back its
1423
+ // fabricated 0-param signature, and `buildSelectedSignature` over THAT
1424
+ // produced a `SelectedSignature` with no rest formal for a call that has
1425
+ // no static arity to check in the first place -- `spread-arguments.ts`'s
1426
+ // `restFormalIndexOf` then refused a range copy into it, the same
1427
+ // "declares 0/1 parameters" fiction one layer further out. Discarding the
1428
+ // fabrication here, after the fact, keeps there from ever being two
1429
+ // authorities to disagree, without moving when either was asked.
1430
+ const calleeTypeShape = context.table.get(calleeType).shape;
1431
+ const calleeIsDynamic = calleeTypeShape.kind === 'primitive' && (calleeTypeShape.primitive === 'any' || calleeTypeShape.primitive === 'unknown');
1432
+ const fabricatedNativeCall = signature !== undefined &&
1433
+ isFabricatedSignatureShape(context.checker, signature) &&
1434
+ structuralCallSignatures(context.table, calleeType) !== null;
1435
+ if (calleeIsDynamic || fabricatedNativeCall) {
1436
+ signature = undefined;
1437
+ selectedSignature = null;
1438
+ }
1439
+ // A bare `super` keyword is not an ordinary value expression -- it is
1440
+ // grammar-restricted to `super(...)`/`super.x` positions, and citing it
1441
+ // through the ordinary `sourceForValue` path (which every ordinary callee
1442
+ // uses) throws, because no family publishes a result for a SyntaxKind the
1443
+ // language itself never lets stand alone. `super(...)`'s callee is a
1444
+ // fresh, correctly-scoped read of the base class's own name instead.
1445
+ const superRead = isSuperCall ? superConstructorRead(context, candidate, node) : null;
1446
+ if (isSuperCall && !superRead) {
1447
+ return {
1448
+ kind: 'blocked',
1449
+ blocker: blocked(candidate.id, 'invocation', 'resolving `super` needs the home object of the enclosing method, which no operation publishes', 'P1')
1450
+ };
1451
+ }
1452
+ // A call whose callee is the `?.`-carrying link of its own chain cites that
1453
+ // link's *present* value, not the value the sub-expression evaluates to.
1454
+ // The two differ exactly here: this call runs inside the guard's present
1455
+ // arm, and the `short-circuit` merge that would otherwise be cited is a phi
1456
+ // in the join block, which does not exist until both arms have closed --
1457
+ // after this call has already run. See `CitedBranch` in `references.ts`.
1458
+ const calleeBranch = isOptionalChain && node.questionDotToken === undefined ? 'present' : 'expression';
1459
+ const calleeSource = superRead ? superRead.source : sourceForValue(context, node.expression, calleeBranch);
1460
+ operands.push(operand('callee', 0, calleeSource, calleeType));
1461
+ // The guard is stated as an operand rather than left for a consumer to
1462
+ // re-derive from the callee's syntax. It duplicates a value another operand
1463
+ // already evaluates -- the callee for `f?.()`, the receiver for `a?.b()` --
1464
+ // so it is provenance, and `ir/lower-short-circuit.ts` reads it to know
1465
+ // which result the merge branches on without asking the AST again.
1466
+ if (shortCircuit)
1467
+ operands.push(operand('short-circuit-guard', 0, shortCircuit.source, context.types.typeAt(shortCircuit.expression)));
1468
+ // `EvaluateNew` calls `Construct(constructor, argList)`, whose new-target
1469
+ // defaults to the constructor itself. Recording it explicitly rather than
1470
+ // letting a consumer assume it is what keeps a derived construction -- where
1471
+ // the two genuinely differ -- from passing as an ordinary one. It is
1472
+ // provenance, not a runtime step: the callee operand already evaluated it.
1473
+ if (ts.isNewExpression(node)) {
1474
+ operands.push(operand('new-target', 0, sourceForValue(context, node.expression), calleeType, { kind: 'provenance' }));
1475
+ }
1476
+ const calleeUnwrapped = unwrapErased(node.expression);
1477
+ // A namespace-qualified callee has no receiver: `Debug.assert(x)` calls a
1478
+ // binding, and `this` inside it is `undefined` exactly as for a bare
1479
+ // `assert(x)` (`namespace-paths.ts`). The namespace is a path, not an
1480
+ // object, so there is no value to pass.
1481
+ const qualified = ts.isPropertyAccessExpression(calleeUnwrapped) && context.namespacePaths.memberSymbolOf(calleeUnwrapped) !== null;
1482
+ if (!qualified && (ts.isPropertyAccessExpression(calleeUnwrapped) || ts.isElementAccessExpression(calleeUnwrapped))) {
1483
+ // A second ?. starts after the previous chain's merge. Its receiver is
1484
+ // that merged value, while suffixes inside the same guard still cite the
1485
+ // present value. Reusing the earlier branch would violate dominance for
1486
+ // a?.b?.method(), whereas a?.b.method() stays inside a's original guard.
1487
+ const receiverBranch = guardExpression !== null && optionalChainGuardOf(calleeUnwrapped.expression) === guardExpression ? 'present' : 'expression';
1488
+ operands.push(operand('receiver', 0, sourceForValue(context, calleeUnwrapped.expression, receiverBranch), context.types.typeAt(calleeUnwrapped.expression), {
1489
+ kind: 'provenance'
1490
+ }));
1491
+ }
1492
+ // An optional call does not evaluate its arguments at all when the guard is
1493
+ // absent: `h.on?.(side())` never calls `side`. Recorded on the operands
1494
+ // exactly as `contributeLogical` records `a && b`'s right-hand side -- this
1495
+ // producer sees one candidate and can state what its own operands do, while
1496
+ // *placing* the argument subtree is `normalize/gating.ts`'s job, since only
1497
+ // a syntax walk knows which expressions the argument list contains.
1498
+ const argumentEvaluation = shortCircuit
1499
+ ? { kind: 'conditional', guard: shortCircuit.result, takenWhen: 'present' }
1500
+ : { kind: 'runtime' };
1501
+ // The argument list, with the two spread shapes that settle statically
1502
+ // (a closed tuple's positional expansion, a plain array's rest-tail range
1503
+ // copy) resolved into operands. `spread-arguments.ts` owns the whole
1504
+ // decision, including the refusals, so the admission rule lives in one
1505
+ // place instead of being split between a gate here and a loop below.
1506
+ const argumentList = buildArgumentOperands(context, candidate, args, argumentEvaluation, selectedSignature, shortCircuit !== null);
1507
+ if (argumentList.kind === 'refused') {
1508
+ return { kind: 'blocked', blocker: blocked(candidate.id, 'invocation', argumentList.reason, 'P4') };
1509
+ }
1510
+ const expansions = argumentList.operations;
1511
+ const expansionEdges = argumentList.edges;
1512
+ operands.push(...argumentList.operands);
1513
+ // This call's own published result stays the checker's real, un-awaited
1514
+ // type -- an un-awaited async call yields a genuine `Promise<T>` value
1515
+ // now that `promise` is a real carrier
1516
+ // (`representation/derive.ts`'s `PromiseDeclarationPolicy`), not an
1517
+ // interim `T`. This used to unwrap via `getAwaitedType`, in lockstep
1518
+ // with the same reverted unwrap in `buildSelectedSignature.returnType`
1519
+ // above and `structural.ts`'s `signatureOf`. `await` unwraps at its own
1520
+ // site instead (`contributeAwait`, producers/control.ts), the only
1521
+ // place ECMAScript itself performs this unwrap. See citations.md
1522
+ // finding 2 for the reverted history.
1523
+ // `JSON.parse(text) as T` is the one call whose own published result
1524
+ // deliberately does NOT stay the checker's real type here: see
1525
+ // `jsonParseResultOverride`'s own comment (above `createInvocationProducer`)
1526
+ // for why substituting the caller's asserted type is safe for this one
1527
+ // ambient global and no other.
1528
+ const jsonParseAssertedType = jsonParseResultOverride(context, node, calleeUnwrapped);
1529
+ // `new Array(n)` is the identical shape of override, at a different
1530
+ // ambient signature -- see `arrayConstructResultOverride`'s own comment.
1531
+ // Checked only when `JSON.parse` didn't already claim this call: the two
1532
+ // receivers never overlap, but keeping the checks mutually exclusive
1533
+ // keeps `resultDivergence` from ever recording two reasons for one call.
1534
+ const arrayConstructAssertedType = jsonParseAssertedType === null && ts.isNewExpression(node) ? arrayConstructResultOverride(context, node, calleeUnwrapped) : null;
1535
+ // `new RangeError(m) as RangeError & { code }` -- the third override of the
1536
+ // same shape. Mutually exclusive with the two above for the same reason
1537
+ // they are with each other: one call, at most one recorded divergence.
1538
+ const errorConstructAssertedType = jsonParseAssertedType === null && arrayConstructAssertedType === null && ts.isNewExpression(node)
1539
+ ? errorConstructResultOverride(context, node, calleeUnwrapped)
1540
+ : null;
1541
+ // `new Map()`/`new Set()`/`new WeakMap()`/`new WeakSet()` -- the fourth
1542
+ // override of the same shape, at the one family the checker DEFAULTS
1543
+ // rather than widens to `any`. Mutually exclusive with the three above
1544
+ // for the same reason they are with each other: none of `JSON.parse`,
1545
+ // `new Array`, and the seven ambient error constructors is ever also a
1546
+ // keyed collection, so at most one of the four is ever recorded.
1547
+ const collectionConstructAssertedType = jsonParseAssertedType === null &&
1548
+ arrayConstructAssertedType === null &&
1549
+ errorConstructAssertedType === null &&
1550
+ ts.isNewExpression(node)
1551
+ ? collectionConstructResultOverride(context, node)
1552
+ : null;
1553
+ // The same census at the collection's other end -- see
1554
+ // `collectionMemberResultOverride`. A `new` expression can never be a
1555
+ // `.get` call, so this stays mutually exclusive with all four above
1556
+ // without needing to test them.
1557
+ // `Object.create(null)` -- the same override at a third `any`-returning
1558
+ // ambient signature. A `new` expression can never be one, so this is
1559
+ // mutually exclusive with the three construct overrides without testing
1560
+ // them; it is checked after `JSON.parse` only because both are calls.
1561
+ const objectCreateAnnotatedType = jsonParseAssertedType === null && ts.isCallExpression(node) ? objectCreateResultOverride(context, node, calleeUnwrapped) : null;
1562
+ const objectAssignTargetType = objectCreateAnnotatedType === null && ts.isCallExpression(node) ? objectAssignTargetOverride(context, node, calleeUnwrapped) : null;
1563
+ // `Object.getOwnPropertyDescriptor(receiver, key)` -- the fifth override
1564
+ // of the same "checker publishes an ambient `any`-carrying signature"
1565
+ // shape. `resultType` below and `selectedSignature.returnType` (set by
1566
+ // this same `objectDescriptorReturnTypeAt` call inside
1567
+ // `buildSelectedSignature`, above) must publish the identical minted type
1568
+ // for `validateInvocationResult` to see them agree -- publishing it only
1569
+ // on one side threw exactly this "invocation result disagrees with
1570
+ // selected return type" failure and silently withheld the whole call
1571
+ // (and, transitively, the binding that cites it) the first time this was
1572
+ // wired up with the override in only one of the two places.
1573
+ const objectDescriptorAssertedType = objectCreateAnnotatedType === null && objectAssignTargetType === null && ts.isCallExpression(node)
1574
+ ? objectDescriptorReturnTypeAt(context, node)
1575
+ : null;
1576
+ const collectionMemberInferredType = objectCreateAnnotatedType === null &&
1577
+ objectAssignTargetType === null &&
1578
+ objectDescriptorAssertedType === null &&
1579
+ ts.isCallExpression(node)
1580
+ ? collectionMemberResultOverride(context, node)
1581
+ : null;
1582
+ // And the bag a call returns -- see `bagResultOverride`. Asked last, so a
1583
+ // `.get` on a censused collection keeps the more specific of the two
1584
+ // reasons: a bag reached through a keyed collection is the same value
1585
+ // arriving by the same call, and one call records one divergence.
1586
+ // A CONSTRUCT can name a bag for the same reason a call can -- JS returns
1587
+ // the object a constructor-invoked function returned -- so the same
1588
+ // divergence covers it. Asked here rather than left to the call arm so
1589
+ // that a bag the census resolves through `new` cannot reach the two
1590
+ // authorities with only one of them moved, which is the shape that made
1591
+ // this producer WITHHOLD when `shapeAt` answered calls unilaterally.
1592
+ const bagInferredType = collectionMemberInferredType === null && (ts.isCallExpression(node) || ts.isNewExpression(node))
1593
+ ? bagResultOverride(context, node)
1594
+ : null;
1595
+ if (jsonParseAssertedType !== null)
1596
+ resultDivergence = { kind: 'json-parse-type-assertion' };
1597
+ else if (arrayConstructAssertedType !== null)
1598
+ resultDivergence = { kind: 'array-construct-type-annotation' };
1599
+ else if (errorConstructAssertedType !== null)
1600
+ resultDivergence = { kind: 'error-construct-type-assertion' };
1601
+ else if (collectionConstructAssertedType !== null)
1602
+ resultDivergence = { kind: 'collection-construct-type-inference' };
1603
+ else if (objectCreateAnnotatedType !== null)
1604
+ resultDivergence = { kind: 'object-create-type-annotation' };
1605
+ else if (objectAssignTargetType !== null)
1606
+ resultDivergence = { kind: 'object-assign-target-identity' };
1607
+ else if (collectionMemberInferredType !== null)
1608
+ resultDivergence = { kind: 'collection-member-type-inference' };
1609
+ else if (bagInferredType !== null)
1610
+ resultDivergence = { kind: 'bag-return-inference' };
1611
+ // Neither override, and no type is substituted: the published result stays
1612
+ // the checker's own `unique symbol`. Only the LICENSE is recorded, because
1613
+ // the two types are the one `{ kind: 'symbol' }` carrier physically and
1614
+ // there is nothing for a consumer to choose between.
1615
+ else if (isUniqueSymbolFreshType(context.checker, node, signature))
1616
+ resultDivergence = { kind: 'unique-symbol-fresh-type' };
1617
+ // `Array.of.call(Pack, ...)` / `Array.prototype.map.call(arrayLike, fn)`:
1618
+ // no type is substituted here either -- `resultType` below already falls
1619
+ // back to `context.types.typeAt(node)`, which `callResultAt` (structural.ts)
1620
+ // already corrected -- only the LICENSE for that correction disagreeing
1621
+ // with `.call`/`.apply`'s own ambient signature is recorded.
1622
+ else if (ts.isCallExpression(node) && isExplicitThisCallWithAuthenticatedReceiver(context, calleeUnwrapped))
1623
+ resultDivergence = { kind: 'explicit-this-call-return' };
1624
+ // The ninth shape of "the checker published an ambient `any` and the
1625
+ // census knows better", and the only one where the better answer is the
1626
+ // CALLEE'S OWN, already selected, already published.
1627
+ //
1628
+ // A receiver the census resolved is one the checker did not. Three reaches
1629
+ // `renderer.state.buffers.depth.getReversed()` through `_this.state =
1630
+ // state`, where `state` is the classic `let state; state = new
1631
+ // WebGLState( ... )` hoist: every link types here -- the operand carrier is
1632
+ // a `native-record-ref` and the callee's is `callable( -> scalar)` -- and
1633
+ // then the RESULT was published `dynamic`, because `typeAt( node )` asks
1634
+ // the checker, for whom `renderer.state` is `any`. One cell, two answers,
1635
+ // and the emitter boxes a scalar it is already calling through an ABI that
1636
+ // returns one.
1637
+ //
1638
+ // Taking the signature's return here is not a new claim: it is the type
1639
+ // this call was already selected to produce, so `validateInvocationResult`
1640
+ // sees the two agree and no divergence license is needed -- the other
1641
+ // eight overrides need one precisely because they disagree with their
1642
+ // signature, and this one does not.
1643
+ //
1644
+ // Narrow deliberately. The fabricated `anySignature` is already discarded
1645
+ // above (`calleeIsDynamic || fabricatedNativeCall` nulls
1646
+ // `selectedSignature`), so a signature that survives is a real one; a
1647
+ // signature returning `any`/`unknown` states nothing to prefer; and an
1648
+ // optional call is left alone, because there the node's own `T | undefined`
1649
+ // is the whole expression's real type and the signature's bare `T` would
1650
+ // silently strip the absent branch the guard exists for.
1651
+ const checkerResultType = context.types.typeAt(node);
1652
+ const publishesNothing = (candidateType) => {
1653
+ const shape = context.table.get(candidateType)?.shape;
1654
+ return shape?.kind === 'primitive' && (shape.primitive === 'any' || shape.primitive === 'unknown');
1655
+ };
1656
+ // `selectedSignature` is the CHECKER's answer, and the checker is exactly
1657
+ // the authority that failed here: it resolves no signature through a
1658
+ // receiver it types `any`, so for the shape this override exists for it is
1659
+ // usually null while the callee's own CARRIER is a fully typed
1660
+ // `callable( -> scalar)`. Fall back to that carrier's signature -- the one
1661
+ // the emitter will actually call through, and the one
1662
+ // `fabricatedNativeCall` above already treats as the true authority when
1663
+ // the checker's disagrees. Only when the checker selected nothing, so the
1664
+ // two can never be published disagreeing; and only for a CALL, since a
1665
+ // `new` names construct signatures these are not.
1666
+ const carriedReturnType = selectedSignature === null && ts.isCallExpression(node)
1667
+ ? (structuralCallSignatures(context.table, calleeType)?.[0]?.result ?? null)
1668
+ : null;
1669
+ const censusedCandidate = selectedSignature !== null ? selectedSignature.returnType : carriedReturnType;
1670
+ const censusedReturnType = censusedCandidate !== null && !shortCircuit && publishesNothing(checkerResultType) && !publishesNothing(censusedCandidate)
1671
+ ? censusedCandidate
1672
+ : null;
1673
+ const resultType = jsonParseAssertedType ??
1674
+ arrayConstructAssertedType ??
1675
+ errorConstructAssertedType ??
1676
+ collectionConstructAssertedType ??
1677
+ objectCreateAnnotatedType ??
1678
+ objectAssignTargetType ??
1679
+ objectDescriptorAssertedType ??
1680
+ collectionMemberInferredType ??
1681
+ bagInferredType ??
1682
+ censusedReturnType ??
1683
+ checkerResultType;
1684
+ // `a?.b()` is typed `T | undefined` by the checker, and both halves are
1685
+ // needed: the whole expression really is that union, while the `[[Call]]`
1686
+ // inside it returns a `T` and never an `undefined` -- it does not run at
1687
+ // all on the branch where the guard was absent. The selected signature's
1688
+ // own return type is that `T`, asked rather than reconstructed; a call
1689
+ // whose overload set the checker withheld has no such answer, and stripping
1690
+ // nullability off the node's type instead would also strip a `T` that
1691
+ // genuinely includes `undefined`, so that shape stays refused by name.
1692
+ // Unless the whole expression is `any`, in which case there is nothing to
1693
+ // strip and no signature to need. `hello?.hosts?.map(...)` is the shape --
1694
+ // `hello: Document | undefined`, `hosts` reached through `Document`'s
1695
+ // `[key: string]: any` index signature, so the callee is `any` and the
1696
+ // checker resolves no signature because there is none to resolve. The
1697
+ // reasoning above does not apply to it: `any | undefined` IS `any`, so
1698
+ // publishing the node's own type strips nothing, and the program asked for
1699
+ // a dynamic value by declaring the index `any`. Refusing instead denied a
1700
+ // carrier to four `ServerDescription` fields and bson's whole
1701
+ // startup-snapshot probe, whose calls are `@ts-expect-error`-marked
1702
+ // optional APIs precisely because nothing declares them.
1703
+ const publishedShape = context.table.get(resultType)?.shape;
1704
+ const publishesDynamic = publishedShape?.kind === 'primitive' && publishedShape.primitive === 'any';
1705
+ if (shortCircuit && !selectedSignature && !publishesDynamic) {
1706
+ return {
1707
+ kind: 'blocked',
1708
+ blocker: blocked(candidate.id, 'invocation', 'an optional call publishes the value its signature returns, and no signature resolved for this call', 'P0')
1709
+ };
1710
+ }
1711
+ // Never clobbers the two override divergences above: `shortCircuit` is only
1712
+ // ever set for an optional CALL, and both overrides are `new` expressions or
1713
+ // an ambient `JSON.parse` receiver, neither of which can be an optional
1714
+ // chain. So at most one of the three reasons is ever recorded for one call.
1715
+ if (shortCircuit)
1716
+ resultDivergence = { kind: 'optional-call-short-circuit' };
1717
+ if (selectedSignature)
1718
+ validateInvocationResult(selectedSignature, resultType, resultDivergence);
1719
+ const intrinsicMutation = intrinsicMutationOf(context, node, calleeUnwrapped);
1720
+ const intrinsicPropertyCall = intrinsicPropertyCallOf(context, node, calleeUnwrapped);
1721
+ const operation = {
1722
+ id: operationIdentity,
1723
+ family: 'invocation',
1724
+ caller: candidate.caller,
1725
+ internalMethod: ts.isNewExpression(node) ? 'construct' : 'call',
1726
+ optionalChain: isOptionalChain,
1727
+ selectedSignature,
1728
+ resultDivergence,
1729
+ target: buildTarget(context, node, signature),
1730
+ ...(builtinModuleLookup?.kind === 'lookup' ? { builtinModuleLookup: builtinModuleLookup.value } : {}),
1731
+ ...(intrinsicMutation ? { intrinsicMutation } : {}),
1732
+ ...(intrinsicPropertyCall === 'own-keys' ? { intrinsicOwnKeys: true } : {}),
1733
+ ...(intrinsicPropertyCall === 'define-property' ? { intrinsicDataDefinition: true } : {}),
1734
+ ...(intrinsicPropertyCall === 'carrier-predicate' ? { intrinsicCarrierPredicate: true } : {}),
1735
+ ...(intrinsicPropertyCall === 'get' ||
1736
+ intrinsicPropertyCall === 'set' ||
1737
+ intrinsicPropertyCall === 'has' ||
1738
+ intrinsicPropertyCall === 'deleteProperty' ||
1739
+ intrinsicPropertyCall === 'getOwnPropertyDescriptor'
1740
+ ? { intrinsicReflection: intrinsicPropertyCall }
1741
+ : {}),
1742
+ operands,
1743
+ conversionRoles: argumentConversionRolesOf(selectedSignature, operands),
1744
+ // Two results, and they are different values. `value` is what the call
1745
+ // returned, which exists only on the branch where the guard was present;
1746
+ // `short-circuit` is what the *expression* evaluates to, which is that
1747
+ // return value on one branch and `undefined` on the other. A consumer of
1748
+ // `a?.b()` wants the second -- that is the operator's whole meaning --
1749
+ // and the first is what `[[Call]]` itself produced, which nothing outside
1750
+ // the present branch may read.
1751
+ results: shortCircuit
1752
+ ? [
1753
+ // A genuinely dynamic optional call has no resolved signature,
1754
+ // but it still has the same two runtime values: the call result
1755
+ // on the present branch and the whole expression after merging
1756
+ // with `undefined`. `any` absorbs that absent arm statically, so
1757
+ // both results use `resultType`; omitting the second result leaves
1758
+ // every consumer citing a value no producer publishes.
1759
+ mintResult(operationIdentity, 'value', selectedSignature?.returnType ?? resultType),
1760
+ mintResult(operationIdentity, 'short-circuit', resultType)
1761
+ ]
1762
+ : [mintResult(operationIdentity, 'value', resultType)],
1763
+ completion: throwingCompletion,
1764
+ // Any call can run arbitrary code, so purity, read, and write are all
1765
+ // conservatively true; nothing downstream may assume otherwise.
1766
+ effects: { readsMutableState: true, writesMutableState: true, allocates: ts.isNewExpression(node), callsUserCode: true },
1767
+ // Evaluation position comes from the shared per-caller counter, never
1768
+ // from a source offset: the two are not comparable, so an operation
1769
+ // ordinalled by offset sorts before every operation ordinalled by count
1770
+ // regardless of the order either actually runs in.
1771
+ evaluationOrdinal: candidate.evaluationOrdinal
1772
+ };
1773
+ // The `[[Call]]` runs only where the guard is present. Stating that as a
1774
+ // conditional edge rather than as a flag on the operation is what lets one
1775
+ // machinery serve `if (a)`, `a && b`, `a?.b` and `a?.b()`: all four are a
1776
+ // guard, a gated region, and a join, and only the question asked of the
1777
+ // guard differs. This edge places the call itself; the argument subtree is
1778
+ // placed by `normalize/gating.ts`, which walks the syntax the arguments
1779
+ // are written in.
1780
+ const shortCircuitEdges = shortCircuit
1781
+ ? [{ kind: 'conditional', guard: shortCircuit.result, to: operationIdentity, takenWhen: 'present' }]
1782
+ : [];
1783
+ const valueEdges = valueEdgesInto(operationIdentity, operands);
1784
+ // The expanded tuple-spread reads are published with the call that cites
1785
+ // them: `contribution.ts` commits one candidate atomically, so operands
1786
+ // naming results from a separately-committed candidate would be withheld
1787
+ // the moment that candidate were blocked.
1788
+ return {
1789
+ kind: 'operations',
1790
+ operations: superRead ? [...superRead.operations, ...expansions, operation] : [...expansions, operation],
1791
+ edges: superRead
1792
+ ? [...superRead.edges, ...expansionEdges, ...valueEdges, ...shortCircuitEdges]
1793
+ : [...expansionEdges, ...valueEdges, ...shortCircuitEdges]
1794
+ };
1795
+ }
1796
+ });