@geastack/compiler 1.0.37 → 1.0.38

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 (536) hide show
  1. package/dist/cli-emit.js +5 -0
  2. package/dist/cli.js +10 -0
  3. package/dist/compiler.d.ts +10 -3
  4. package/dist/compiler.js +364 -224
  5. package/dist/conversion/build.d.ts +13 -1
  6. package/dist/conversion/build.js +336 -141
  7. package/dist/conversion/graph-validation.d.ts +7 -2
  8. package/dist/conversion/graph-validation.js +36 -22
  9. package/dist/conversion/native-sum.js +106 -17
  10. package/dist/diagnostics/sweep.js +1 -1
  11. package/dist/ir/callable-class-flow.d.ts +0 -11
  12. package/dist/ir/callable-class-flow.js +970 -169
  13. package/dist/ir/certificate.d.ts +1 -1
  14. package/dist/ir/certificate.js +12 -1
  15. package/dist/ir/certify/carrier-keys.d.ts +17 -1
  16. package/dist/ir/certify/carrier-keys.js +35 -2
  17. package/dist/ir/certify/function-source.js +2 -1
  18. package/dist/ir/certify/has-property-key.d.ts +6 -0
  19. package/dist/ir/certify/has-property-key.js +8 -1
  20. package/dist/ir/certify/property-access-keys.js +2 -1
  21. package/dist/ir/certify/runtime-helper.js +2 -1
  22. package/dist/ir/emission-representations.d.ts +2 -2
  23. package/dist/ir/emission-representations.js +9 -3
  24. package/dist/ir/generic-call-entry.d.ts +3 -1
  25. package/dist/ir/logical-receivers.js +29 -1
  26. package/dist/ir/lower-completion.js +11 -6
  27. package/dist/ir/lower-destructuring.js +3 -2
  28. package/dist/ir/native-host-method-reads.d.ts +5 -0
  29. package/dist/ir/native-host-method-reads.js +30 -21
  30. package/dist/ir/operation-conversions.js +4 -1
  31. package/dist/ir/publish-conversion-recipes.js +12 -1
  32. package/dist/plugins/apple/jsx.js +1 -1
  33. package/dist/plugins/gea/component-classes.js +1 -1
  34. package/dist/plugins/gea/component-inline.js +1 -1
  35. package/dist/plugins/gea/contract.d.ts +1 -1
  36. package/dist/plugins/gea/contract.js +1 -1
  37. package/dist/plugins/gea/host.js +27 -1
  38. package/dist/plugins/gea/lower.js +8 -1
  39. package/dist/plugins/gea/producer.js +1 -1
  40. package/dist/plugins/gea/reactive-slots.d.ts +1 -1
  41. package/dist/plugins/gea/reactive-slots.js +1 -1
  42. package/dist/plugins/load.js +51 -22
  43. package/dist/preflight/run.d.ts +12 -1
  44. package/dist/preflight/run.js +65 -29
  45. package/dist/projection/native-callable-data.js +2 -1
  46. package/dist/representation/plan.js +102 -4
  47. package/dist/semantics/alias-this-field-declaration-transform.js +1 -1
  48. package/dist/semantics/ambient-type-realization-transform.js +1 -1
  49. package/dist/semantics/ambient.d.ts +1 -1
  50. package/dist/semantics/ambient.js +1 -1
  51. package/dist/semantics/borrowed-builtin-call-bind-source-transform.js +1 -1
  52. package/dist/semantics/borrowed-method-receiver-copy-source-transform.js +1 -1
  53. package/dist/semantics/call-invalidated-narrowing.d.ts +1 -1
  54. package/dist/semantics/call-invalidated-narrowing.js +4 -2
  55. package/dist/semantics/callable-own-data-slots.d.ts +6 -0
  56. package/dist/semantics/callable-own-data-slots.js +177 -101
  57. package/dist/semantics/class-alias.d.ts +1 -1
  58. package/dist/semantics/class-alias.js +1 -1
  59. package/dist/semantics/class-heritage.d.ts +1 -1
  60. package/dist/semantics/class-heritage.js +1 -1
  61. package/dist/semantics/commonjs-wrapper.d.ts +4 -3
  62. package/dist/semantics/commonjs-wrapper.js +50 -7
  63. package/dist/semantics/constructor-function-class-source-transform.js +1 -1
  64. package/dist/semantics/constructor-slot-subclasses.d.ts +1 -1
  65. package/dist/semantics/constructor-slot-subclasses.js +1 -1
  66. package/dist/semantics/declaration-overlay-transform.js +3 -2
  67. package/dist/semantics/declared-integers.d.ts +1 -1
  68. package/dist/semantics/declared-integers.js +1 -1
  69. package/dist/semantics/define-property-source-transform.js +1 -1
  70. package/dist/semantics/diagnostic-source-preparation.d.ts +1 -1
  71. package/dist/semantics/documentation-ranges.d.ts +1 -1
  72. package/dist/semantics/documentation-ranges.js +1 -1
  73. package/dist/semantics/dynamic-fallback.d.ts +1 -1
  74. package/dist/semantics/dynamic-fallback.js +1 -1
  75. package/dist/semantics/frontend-timing.js +19 -0
  76. package/dist/semantics/frontend.d.ts +2 -2
  77. package/dist/semantics/frontend.js +127 -54
  78. package/dist/semantics/host-declaration-provenance.d.ts +1 -1
  79. package/dist/semantics/host-methods.d.ts +1 -1
  80. package/dist/semantics/host-methods.js +1 -1
  81. package/dist/semantics/host-protocols.d.ts +1 -1
  82. package/dist/semantics/host-protocols.js +1 -1
  83. package/dist/semantics/inherited-accessor.d.ts +1 -1
  84. package/dist/semantics/inherited-accessor.js +1 -1
  85. package/dist/semantics/interface-families.d.ts +1 -1
  86. package/dist/semantics/interface-families.js +1 -1
  87. package/dist/semantics/interface-implementors.d.ts +1 -1
  88. package/dist/semantics/interface-implementors.js +1 -1
  89. package/dist/semantics/jsdoc-namepath-transform.js +1 -1
  90. package/dist/semantics/jsx-runtime-provider.d.ts +1 -1
  91. package/dist/semantics/jsx-runtime-provider.js +1 -1
  92. package/dist/semantics/known-caller-predicate-parameters.d.ts +1 -1
  93. package/dist/semantics/known-caller-predicate-parameters.js +1 -1
  94. package/dist/semantics/model/edges.d.ts +124 -0
  95. package/dist/semantics/model/edges.js +192 -0
  96. package/dist/semantics/model/graph.d.ts +26 -2
  97. package/dist/semantics/model/graph.js +54 -0
  98. package/dist/semantics/model/sealed-facts.d.ts +19 -0
  99. package/dist/semantics/model/sealed-facts.js +221 -0
  100. package/dist/semantics/model/selected-signature.d.ts +1 -1
  101. package/dist/semantics/model/selected-signature.js +1 -1
  102. package/dist/semantics/module-resolution.d.ts +1 -1
  103. package/dist/semantics/module-resolution.js +1 -1
  104. package/dist/semantics/native-function-signatures.d.ts +1 -1
  105. package/dist/semantics/native-function-signatures.js +1 -1
  106. package/dist/semantics/native-object-data-slots.js +20 -4
  107. package/dist/semantics/new-callee-class-tag-source-transform.js +1 -1
  108. package/dist/semantics/node-project.d.ts +1 -1
  109. package/dist/semantics/node-project.js +1 -1
  110. package/dist/semantics/node-source-hooks.js +1 -1
  111. package/dist/semantics/normalize/absent-globals.d.ts +1 -1
  112. package/dist/semantics/normalize/absent-globals.js +1 -1
  113. package/dist/semantics/normalize/any-cast-member-call.d.ts +1 -1
  114. package/dist/semantics/normalize/any-cast-member-call.js +1 -1
  115. package/dist/semantics/normalize/arguments-objects.d.ts +1 -1
  116. package/dist/semantics/normalize/arguments-objects.js +1 -1
  117. package/dist/semantics/normalize/asserted-argument-arms.d.ts +1 -1
  118. package/dist/semantics/normalize/asserted-argument-arms.js +1 -1
  119. package/dist/semantics/normalize/asserted-arm-absence.d.ts +1 -1
  120. package/dist/semantics/normalize/asserted-arm-absence.js +1 -1
  121. package/dist/semantics/normalize/assignment-patterns.d.ts +1 -1
  122. package/dist/semantics/normalize/assignment-patterns.js +1 -1
  123. package/dist/semantics/normalize/bag-absence.d.ts +1 -1
  124. package/dist/semantics/normalize/bag-absence.js +1 -1
  125. package/dist/semantics/normalize/binding-fixpoint.js +9 -2
  126. package/dist/semantics/normalize/bivariant-slot-parameter.d.ts +1 -1
  127. package/dist/semantics/normalize/bivariant-slot-parameter.js +1 -1
  128. package/dist/semantics/normalize/callable-data-write.d.ts +1 -1
  129. package/dist/semantics/normalize/callable-data-write.js +1 -1
  130. package/dist/semantics/normalize/callback-parameter-contracts.d.ts +1 -1
  131. package/dist/semantics/normalize/callback-parameter-contracts.js +1 -1
  132. package/dist/semantics/normalize/cells/agreement.d.ts +18 -1
  133. package/dist/semantics/normalize/cells/agreement.js +8 -0
  134. package/dist/semantics/normalize/cells/candidates.d.ts +1 -1
  135. package/dist/semantics/normalize/cells/candidates.js +1 -1
  136. package/dist/semantics/normalize/cells/facts.d.ts +1 -1
  137. package/dist/semantics/normalize/cells/facts.js +1 -1
  138. package/dist/semantics/normalize/cells/index.d.ts +2 -2
  139. package/dist/semantics/normalize/cells/index.js +1 -1
  140. package/dist/semantics/normalize/cells/model.d.ts +1 -1
  141. package/dist/semantics/normalize/cells/policies/bag.d.ts +1 -1
  142. package/dist/semantics/normalize/cells/policies/collection.d.ts +1 -1
  143. package/dist/semantics/normalize/cells/policies/collection.js +1 -1
  144. package/dist/semantics/normalize/cells/policies/field.d.ts +1 -1
  145. package/dist/semantics/normalize/cells/policies/field.js +1 -1
  146. package/dist/semantics/normalize/cells/policies/index.d.ts +1 -1
  147. package/dist/semantics/normalize/cells/policies/local.d.ts +1 -1
  148. package/dist/semantics/normalize/cells/policies/local.js +1 -1
  149. package/dist/semantics/normalize/cells/policies/parameter.d.ts +1 -1
  150. package/dist/semantics/normalize/cells/policies/parameter.js +1 -1
  151. package/dist/semantics/normalize/cells/policies/return.d.ts +1 -1
  152. package/dist/semantics/normalize/cells/policies/return.js +1 -1
  153. package/dist/semantics/normalize/cells/policies/shared.d.ts +1 -1
  154. package/dist/semantics/normalize/cells/policy.d.ts +1 -1
  155. package/dist/semantics/normalize/census.d.ts +1 -1
  156. package/dist/semantics/normalize/census.js +45 -12
  157. package/dist/semantics/normalize/class-instance-record-statement.d.ts +1 -1
  158. package/dist/semantics/normalize/class-instance-record-statement.js +1 -1
  159. package/dist/semantics/normalize/collection-bindings.d.ts +1 -1
  160. package/dist/semantics/normalize/collection-bindings.js +1 -1
  161. package/dist/semantics/normalize/commonjs-module-record.d.ts +1 -1
  162. package/dist/semantics/normalize/commonjs-module-record.js +1 -1
  163. package/dist/semantics/normalize/commonjs-require.d.ts +1 -1
  164. package/dist/semantics/normalize/commonjs-require.js +1 -1
  165. package/dist/semantics/normalize/contribution.d.ts +4 -3
  166. package/dist/semantics/normalize/contribution.js +145 -42
  167. package/dist/semantics/normalize/dead-event-emissions.d.ts +1 -1
  168. package/dist/semantics/normalize/dead-event-emissions.js +1 -1
  169. package/dist/semantics/normalize/dead-method-copies.d.ts +1 -1
  170. package/dist/semantics/normalize/dead-method-copies.js +1 -1
  171. package/dist/semantics/normalize/dead-typeof-guards.d.ts +1 -1
  172. package/dist/semantics/normalize/dead-typeof-guards.js +1 -1
  173. package/dist/semantics/normalize/deferred-intrinsic-protocols.d.ts +1 -1
  174. package/dist/semantics/normalize/deferred-intrinsic-protocols.js +1 -1
  175. package/dist/semantics/normalize/derived-expression-type.d.ts +1 -1
  176. package/dist/semantics/normalize/derived-expression-type.js +4 -4
  177. package/dist/semantics/normalize/evaluation-order.d.ts +1 -1
  178. package/dist/semantics/normalize/evaluation-order.js +1 -1
  179. package/dist/semantics/normalize/field-bindings.d.ts +1 -1
  180. package/dist/semantics/normalize/field-bindings.js +4 -3
  181. package/dist/semantics/normalize/flow/array-element-continuation.d.ts +1 -1
  182. package/dist/semantics/normalize/flow/array-element-continuation.js +3 -3
  183. package/dist/semantics/normalize/flow/callable-array-origins.d.ts +1 -1
  184. package/dist/semantics/normalize/flow/callable-array-origins.js +1 -1
  185. package/dist/semantics/normalize/flow/callable-completions.d.ts +1 -1
  186. package/dist/semantics/normalize/flow/callable-completions.js +1 -1
  187. package/dist/semantics/normalize/flow/callable-reach.d.ts +1 -1
  188. package/dist/semantics/normalize/flow/callable-reach.js +73 -52
  189. package/dist/semantics/normalize/flow/class-family-member-read.d.ts +1 -1
  190. package/dist/semantics/normalize/flow/class-family-member-read.js +3 -3
  191. package/dist/semantics/normalize/flow/collection-value-continuation.d.ts +1 -1
  192. package/dist/semantics/normalize/flow/collection-value-continuation.js +1 -1
  193. package/dist/semantics/normalize/flow/component-solver.d.ts +181 -3
  194. package/dist/semantics/normalize/flow/component-solver.js +705 -164
  195. package/dist/semantics/normalize/flow/computed-key-set.d.ts +1 -1
  196. package/dist/semantics/normalize/flow/computed-key-set.js +1 -1
  197. package/dist/semantics/normalize/flow/export-importers.d.ts +1 -1
  198. package/dist/semantics/normalize/flow/export-importers.js +13 -3
  199. package/dist/semantics/normalize/flow/host-text-sink.d.ts +1 -1
  200. package/dist/semantics/normalize/flow/host-text-sink.js +1 -1
  201. package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.d.ts +1 -1
  202. package/dist/semantics/normalize/flow/intrinsic-array-callback-frames.js +1 -1
  203. package/dist/semantics/normalize/flow/intrinsic-data-definition.d.ts +1 -1
  204. package/dist/semantics/normalize/flow/intrinsic-data-definition.js +1 -1
  205. package/dist/semantics/normalize/flow/invocation-facts.d.ts +1 -1
  206. package/dist/semantics/normalize/flow/invocation-facts.js +1 -1
  207. package/dist/semantics/normalize/flow/member-call-forwarding.d.ts +1 -1
  208. package/dist/semantics/normalize/flow/member-call-forwarding.js +1 -1
  209. package/dist/semantics/normalize/flow/model.d.ts +1 -1
  210. package/dist/semantics/normalize/flow/model.js +5 -1
  211. package/dist/semantics/normalize/flow/native-collection-protocol.d.ts +1 -1
  212. package/dist/semantics/normalize/flow/native-collection-protocol.js +1 -1
  213. package/dist/semantics/normalize/flow/node-path-token.d.ts +1 -1
  214. package/dist/semantics/normalize/flow/object-binding-continuation.d.ts +1 -1
  215. package/dist/semantics/normalize/flow/object-binding-continuation.js +1 -1
  216. package/dist/semantics/normalize/flow/origin-authority.d.ts +1 -1
  217. package/dist/semantics/normalize/flow/owned-class-receivers.d.ts +1 -1
  218. package/dist/semantics/normalize/flow/owned-class-receivers.js +1 -1
  219. package/dist/semantics/normalize/flow/parameter-values.d.ts +1 -1
  220. package/dist/semantics/normalize/flow/parameter-values.js +1 -1
  221. package/dist/semantics/normalize/flow/record-alias-closure.d.ts +1 -1
  222. package/dist/semantics/normalize/flow/record-alias-closure.js +1 -1
  223. package/dist/semantics/normalize/flow/seeded-origins.d.ts +1 -1
  224. package/dist/semantics/normalize/flow/seeded-origins.js +1 -1
  225. package/dist/semantics/normalize/flow/source-accessor-descriptor.d.ts +1 -1
  226. package/dist/semantics/normalize/flow/source-accessor-descriptor.js +1 -1
  227. package/dist/semantics/normalize/flow/source-callable-own-data.d.ts +1 -1
  228. package/dist/semantics/normalize/flow/source-callable-own-data.js +1 -1
  229. package/dist/semantics/normalize/flow/source-callable-readonly-set.d.ts +1 -1
  230. package/dist/semantics/normalize/flow/source-callable-readonly-set.js +1 -1
  231. package/dist/semantics/normalize/flow/source-class-data.d.ts +1 -1
  232. package/dist/semantics/normalize/flow/source-class-data.js +1 -1
  233. package/dist/semantics/normalize/flow/source-class-instanceof.d.ts +1 -1
  234. package/dist/semantics/normalize/flow/source-class-instanceof.js +1 -1
  235. package/dist/semantics/normalize/flow/source-class-static-data.d.ts +1 -1
  236. package/dist/semantics/normalize/flow/source-class-static-data.js +1 -1
  237. package/dist/semantics/normalize/flow/source-commonjs-exports.d.ts +1 -1
  238. package/dist/semantics/normalize/flow/source-construction-frames.d.ts +1 -1
  239. package/dist/semantics/normalize/flow/source-construction-frames.js +1 -1
  240. package/dist/semantics/normalize/flow/source-descriptor-protocol.d.ts +1 -1
  241. package/dist/semantics/normalize/flow/source-descriptor-protocol.js +1 -1
  242. package/dist/semantics/normalize/flow/source-executing-parameter-values.d.ts +1 -1
  243. package/dist/semantics/normalize/flow/source-executing-parameter-values.js +1 -1
  244. package/dist/semantics/normalize/flow/source-global-binding.d.ts +1 -1
  245. package/dist/semantics/normalize/flow/source-global-binding.js +1 -1
  246. package/dist/semantics/normalize/flow/source-intrinsic-member-data.d.ts +1 -1
  247. package/dist/semantics/normalize/flow/source-intrinsic-member-data.js +1 -1
  248. package/dist/semantics/normalize/flow/source-invocation-frame-layout.d.ts +1 -1
  249. package/dist/semantics/normalize/flow/source-invocation-frame-layout.js +24 -32
  250. package/dist/semantics/normalize/flow/source-invocation-receiver.d.ts +1 -1
  251. package/dist/semantics/normalize/flow/source-invocation-receiver.js +1 -1
  252. package/dist/semantics/normalize/flow/source-native-class-alias.d.ts +1 -1
  253. package/dist/semantics/normalize/flow/source-native-class-alias.js +1 -1
  254. package/dist/semantics/normalize/flow/source-native-iterable-integrity.d.ts +1 -1
  255. package/dist/semantics/normalize/flow/source-native-iterable-integrity.js +1 -1
  256. package/dist/semantics/normalize/flow/source-native-origin.d.ts +1 -1
  257. package/dist/semantics/normalize/flow/source-native-origin.js +1 -1
  258. package/dist/semantics/normalize/flow/source-normal-predecessor.d.ts +1 -1
  259. package/dist/semantics/normalize/flow/source-normal-predecessor.js +1 -1
  260. package/dist/semantics/normalize/flow/source-property-key.d.ts +1 -1
  261. package/dist/semantics/normalize/flow/source-property-key.js +1 -1
  262. package/dist/semantics/normalize/flow/source-prototype-method-identity.d.ts +1 -1
  263. package/dist/semantics/normalize/flow/source-prototype-method-identity.js +1 -1
  264. package/dist/semantics/normalize/flow/source-proxy-operation.d.ts +1 -1
  265. package/dist/semantics/normalize/flow/source-proxy-operation.js +1 -1
  266. package/dist/semantics/normalize/flow/source-raw-constructor-entry.d.ts +1 -1
  267. package/dist/semantics/normalize/flow/source-raw-constructor-entry.js +1 -1
  268. package/dist/semantics/normalize/flow/source-read-protocol.d.ts +1 -1
  269. package/dist/semantics/normalize/flow/source-read-protocol.js +1 -1
  270. package/dist/semantics/normalize/flow/source-record-data.d.ts +1 -1
  271. package/dist/semantics/normalize/flow/source-record-data.js +1 -1
  272. package/dist/semantics/normalize/flow/source-value-session.d.ts +33 -3
  273. package/dist/semantics/normalize/flow/source-value-session.js +381 -173
  274. package/dist/semantics/normalize/flow/standard-prototype-method-source.d.ts +1 -1
  275. package/dist/semantics/normalize/flow/standard-prototype-method-source.js +1 -1
  276. package/dist/semantics/normalize/flow/targets.d.ts +1 -1
  277. package/dist/semantics/normalize/flow/targets.js +1 -1
  278. package/dist/semantics/normalize/flow/value-flow.d.ts +1 -1
  279. package/dist/semantics/normalize/flow/value-flow.js +243 -52
  280. package/dist/semantics/normalize/flow/value-provenance.d.ts +1 -1
  281. package/dist/semantics/normalize/flow/value-provenance.js +1 -1
  282. package/dist/semantics/normalize/fresh-dictionary-storage.d.ts +1 -1
  283. package/dist/semantics/normalize/fresh-dictionary-storage.js +1 -1
  284. package/dist/semantics/normalize/fresh-ordinary-object.d.ts +1 -1
  285. package/dist/semantics/normalize/fresh-ordinary-object.js +1 -1
  286. package/dist/semantics/normalize/fresh-table-last-use.d.ts +1 -1
  287. package/dist/semantics/normalize/fresh-table-last-use.js +1 -1
  288. package/dist/semantics/normalize/gating.d.ts +3 -3
  289. package/dist/semantics/normalize/gating.js +17 -20
  290. package/dist/semantics/normalize/generic-function-choice.d.ts +1 -1
  291. package/dist/semantics/normalize/generic-function-choice.js +1 -1
  292. package/dist/semantics/normalize/global-host-mutations.d.ts +1 -1
  293. package/dist/semantics/normalize/global-host-mutations.js +420 -138
  294. package/dist/semantics/normalize/host-effect-contracts.d.ts +1 -1
  295. package/dist/semantics/normalize/host-effect-contracts.js +1 -1
  296. package/dist/semantics/normalize/host-mutation-computed-keys.d.ts +1 -1
  297. package/dist/semantics/normalize/host-mutation-key-reader.d.ts +1 -1
  298. package/dist/semantics/normalize/host-mutation-key-reader.js +1 -1
  299. package/dist/semantics/normalize/identities.d.ts +41 -1
  300. package/dist/semantics/normalize/identities.js +75 -9
  301. package/dist/semantics/normalize/implicit-arguments-tuple.d.ts +1 -1
  302. package/dist/semantics/normalize/implicit-arguments-tuple.js +1 -1
  303. package/dist/semantics/normalize/implicit-arguments.d.ts +1 -1
  304. package/dist/semantics/normalize/implicit-arguments.js +1 -1
  305. package/dist/semantics/normalize/installed-global-properties.d.ts +1 -1
  306. package/dist/semantics/normalize/installed-global-properties.js +1 -1
  307. package/dist/semantics/normalize/instantiation.d.ts +1 -1
  308. package/dist/semantics/normalize/instantiation.js +1 -1
  309. package/dist/semantics/normalize/intrinsic-accessor-getter.d.ts +1 -1
  310. package/dist/semantics/normalize/intrinsic-accessor-getter.js +1 -1
  311. package/dist/semantics/normalize/intrinsic-property-call.d.ts +1 -1
  312. package/dist/semantics/normalize/intrinsic-property-call.js +1 -1
  313. package/dist/semantics/normalize/intrinsic-prototype.d.ts +1 -1
  314. package/dist/semantics/normalize/intrinsic-prototype.js +1 -1
  315. package/dist/semantics/normalize/intrinsic-return-identity.d.ts +1 -1
  316. package/dist/semantics/normalize/intrinsic-return-identity.js +1 -1
  317. package/dist/semantics/normalize/intrinsic-static-member.d.ts +1 -1
  318. package/dist/semantics/normalize/jsdoc-type-names.d.ts +1 -1
  319. package/dist/semantics/normalize/jsdoc-type-names.js +1 -1
  320. package/dist/semantics/normalize/local-bindings.d.ts +1 -1
  321. package/dist/semantics/normalize/local-bindings.js +3 -2
  322. package/dist/semantics/normalize/logical-object-truthiness.d.ts +1 -1
  323. package/dist/semantics/normalize/logical-object-truthiness.js +1 -1
  324. package/dist/semantics/normalize/logical-result-type.d.ts +1 -1
  325. package/dist/semantics/normalize/logical-result-type.js +1 -1
  326. package/dist/semantics/normalize/merged-declaration.d.ts +1 -1
  327. package/dist/semantics/normalize/merged-declaration.js +1 -1
  328. package/dist/semantics/normalize/namespace-paths.d.ts +1 -1
  329. package/dist/semantics/normalize/namespace-paths.js +1 -1
  330. package/dist/semantics/normalize/never-override-result.d.ts +1 -1
  331. package/dist/semantics/normalize/never-override-result.js +1 -1
  332. package/dist/semantics/normalize/normalize.d.ts +23 -4
  333. package/dist/semantics/normalize/normalize.js +125 -15
  334. package/dist/semantics/normalize/null-blind-parameter.d.ts +1 -1
  335. package/dist/semantics/normalize/null-blind-parameter.js +1 -1
  336. package/dist/semantics/normalize/nullable-memo.d.ts +28 -0
  337. package/dist/semantics/normalize/nullable-memo.js +99 -0
  338. package/dist/semantics/normalize/object-bag-bindings.d.ts +1 -1
  339. package/dist/semantics/normalize/object-bag-bindings.js +15 -4
  340. package/dist/semantics/normalize/omitted-stated-parameter.d.ts +1 -1
  341. package/dist/semantics/normalize/omitted-stated-parameter.js +1 -1
  342. package/dist/semantics/normalize/open-type-form.d.ts +1 -1
  343. package/dist/semantics/normalize/open-type-form.js +1 -1
  344. package/dist/semantics/normalize/override-field-arms.d.ts +1 -1
  345. package/dist/semantics/normalize/override-field-arms.js +1 -1
  346. package/dist/semantics/normalize/parameter-bindings.d.ts +1 -52
  347. package/dist/semantics/normalize/parameter-bindings.js +105 -10
  348. package/dist/semantics/normalize/parameter-slot.d.ts +1 -1
  349. package/dist/semantics/normalize/parameter-slot.js +1 -1
  350. package/dist/semantics/normalize/physical-overload-result.d.ts +1 -1
  351. package/dist/semantics/normalize/physical-overload-result.js +1 -1
  352. package/dist/semantics/normalize/primitive-property-absence.d.ts +1 -1
  353. package/dist/semantics/normalize/producer-context.d.ts +1 -1
  354. package/dist/semantics/normalize/producers/allocations.d.ts +1 -1
  355. package/dist/semantics/normalize/producers/allocations.js +1 -1
  356. package/dist/semantics/normalize/producers/binding-kind.d.ts +1 -1
  357. package/dist/semantics/normalize/producers/binding-kind.js +1 -1
  358. package/dist/semantics/normalize/producers/bindings.d.ts +1 -1
  359. package/dist/semantics/normalize/producers/bindings.js +1 -1
  360. package/dist/semantics/normalize/producers/boundary.d.ts +1 -1
  361. package/dist/semantics/normalize/producers/boundary.js +1 -1
  362. package/dist/semantics/normalize/producers/cited-value-type.d.ts +1 -1
  363. package/dist/semantics/normalize/producers/cited-value-type.js +1 -1
  364. package/dist/semantics/normalize/producers/class-lifecycle.js +1 -1
  365. package/dist/semantics/normalize/producers/computations.js +1 -1
  366. package/dist/semantics/normalize/producers/conditional-guard.d.ts +1 -1
  367. package/dist/semantics/normalize/producers/control-loops.d.ts +1 -1
  368. package/dist/semantics/normalize/producers/control-loops.js +1 -1
  369. package/dist/semantics/normalize/producers/control.d.ts +1 -1
  370. package/dist/semantics/normalize/producers/control.js +1 -1
  371. package/dist/semantics/normalize/producers/declaration-lifecycle.js +1 -1
  372. package/dist/semantics/normalize/producers/destructuring.d.ts +1 -1
  373. package/dist/semantics/normalize/producers/destructuring.js +1 -1
  374. package/dist/semantics/normalize/producers/dynamic-language.js +1 -1
  375. package/dist/semantics/normalize/producers/enums.d.ts +1 -1
  376. package/dist/semantics/normalize/producers/enums.js +1 -1
  377. package/dist/semantics/normalize/producers/erasure.d.ts +1 -1
  378. package/dist/semantics/normalize/producers/erasure.js +1 -1
  379. package/dist/semantics/normalize/producers/exact-arms.d.ts +1 -1
  380. package/dist/semantics/normalize/producers/exact-arms.js +1 -1
  381. package/dist/semantics/normalize/producers/intrinsic-accessor-getter.d.ts +1 -1
  382. package/dist/semantics/normalize/producers/invocations.d.ts +1 -1
  383. package/dist/semantics/normalize/producers/invocations.js +1 -1
  384. package/dist/semantics/normalize/producers/iteration-yield.d.ts +1 -1
  385. package/dist/semantics/normalize/producers/iteration-yield.js +1 -1
  386. package/dist/semantics/normalize/producers/jsx.js +1 -1
  387. package/dist/semantics/normalize/producers/logical-merge-type.d.ts +1 -1
  388. package/dist/semantics/normalize/producers/logical-merge-type.js +1 -1
  389. package/dist/semantics/normalize/producers/mint.js +88 -5
  390. package/dist/semantics/normalize/producers/native-callable-readonly-set.d.ts +1 -1
  391. package/dist/semantics/normalize/producers/native-own-assignment.d.ts +1 -1
  392. package/dist/semantics/normalize/producers/native-own-assignment.js +1 -1
  393. package/dist/semantics/normalize/producers/nullish.d.ts +1 -1
  394. package/dist/semantics/normalize/producers/nullish.js +1 -1
  395. package/dist/semantics/normalize/producers/object-assignment.d.ts +1 -1
  396. package/dist/semantics/normalize/producers/object-assignment.js +1 -1
  397. package/dist/semantics/normalize/producers/object-tag.d.ts +1 -1
  398. package/dist/semantics/normalize/producers/object-tag.js +1 -1
  399. package/dist/semantics/normalize/producers/optional-chain.d.ts +1 -1
  400. package/dist/semantics/normalize/producers/optional-chain.js +1 -1
  401. package/dist/semantics/normalize/producers/properties.d.ts +1 -1
  402. package/dist/semantics/normalize/producers/properties.js +1 -1
  403. package/dist/semantics/normalize/producers/protocol.d.ts +1 -1
  404. package/dist/semantics/normalize/producers/protocol.js +1 -1
  405. package/dist/semantics/normalize/producers/references.d.ts +1 -1
  406. package/dist/semantics/normalize/producers/references.js +1 -1
  407. package/dist/semantics/normalize/producers/shared.d.ts +1 -1
  408. package/dist/semantics/normalize/producers/shared.js +1 -1
  409. package/dist/semantics/normalize/producers/spread-arguments.d.ts +1 -1
  410. package/dist/semantics/normalize/producers/spread-arguments.js +1 -1
  411. package/dist/semantics/normalize/producers/tagged-template.d.ts +1 -1
  412. package/dist/semantics/normalize/producers/tagged-template.js +1 -1
  413. package/dist/semantics/normalize/producers/tuple-spread.d.ts +1 -1
  414. package/dist/semantics/normalize/producers/tuple-spread.js +1 -1
  415. package/dist/semantics/normalize/property-key-domain.d.ts +8 -1
  416. package/dist/semantics/normalize/property-key-domain.js +74 -47
  417. package/dist/semantics/normalize/reachability.d.ts +1 -1
  418. package/dist/semantics/normalize/reachability.js +3 -2
  419. package/dist/semantics/normalize/reassigned-bindings.d.ts +1 -1
  420. package/dist/semantics/normalize/record-home-arms.d.ts +1 -1
  421. package/dist/semantics/normalize/record-home-arms.js +1 -1
  422. package/dist/semantics/normalize/record-link-families.d.ts +1 -1
  423. package/dist/semantics/normalize/record-link-families.js +1 -1
  424. package/dist/semantics/normalize/record-stand-in-arms.d.ts +1 -1
  425. package/dist/semantics/normalize/record-stand-in-arms.js +1 -1
  426. package/dist/semantics/normalize/record-storage-families.d.ts +1 -1
  427. package/dist/semantics/normalize/record-storage-families.js +1 -1
  428. package/dist/semantics/normalize/return-bindings.d.ts +1 -1
  429. package/dist/semantics/normalize/return-bindings.js +1 -1
  430. package/dist/semantics/normalize/return-paths.d.ts +1 -1
  431. package/dist/semantics/normalize/return-paths.js +1 -1
  432. package/dist/semantics/normalize/round-tables.d.ts +21 -0
  433. package/dist/semantics/normalize/round-tables.js +59 -0
  434. package/dist/semantics/normalize/script-global-redefinition.d.ts +1 -1
  435. package/dist/semantics/normalize/script-global-redefinition.js +1 -1
  436. package/dist/semantics/normalize/shared-array-storage.d.ts +1 -1
  437. package/dist/semantics/normalize/shared-array-storage.js +1 -1
  438. package/dist/semantics/normalize/sloppy-absence.d.ts +1 -1
  439. package/dist/semantics/normalize/sloppy-absence.js +1 -1
  440. package/dist/semantics/normalize/source-native-iterable.d.ts +2 -2
  441. package/dist/semantics/normalize/source-native-iterable.js +4 -2
  442. package/dist/semantics/normalize/source-object-prototype-absence.d.ts +1 -1
  443. package/dist/semantics/normalize/source-object-prototype-absence.js +1 -1
  444. package/dist/semantics/normalize/specialization.d.ts +1 -1
  445. package/dist/semantics/normalize/specialization.js +1 -1
  446. package/dist/semantics/normalize/specialized-source-frames.d.ts +1 -1
  447. package/dist/semantics/normalize/specialized-source-frames.js +12 -4
  448. package/dist/semantics/normalize/structural-any-binding-consumer.d.ts +1 -1
  449. package/dist/semantics/normalize/structural-any-binding-consumer.js +1 -1
  450. package/dist/semantics/normalize/structural-array-element.d.ts +1 -1
  451. package/dist/semantics/normalize/structural-array-element.js +1 -1
  452. package/dist/semantics/normalize/structural-array-read.d.ts +1 -1
  453. package/dist/semantics/normalize/structural-array-read.js +1 -1
  454. package/dist/semantics/normalize/structural-callable.d.ts +1 -1
  455. package/dist/semantics/normalize/structural-callable.js +1 -1
  456. package/dist/semantics/normalize/structural-creation-order.d.ts +1 -1
  457. package/dist/semantics/normalize/structural-creation-order.js +1 -1
  458. package/dist/semantics/normalize/structural-declarations.d.ts +1 -1
  459. package/dist/semantics/normalize/structural-declarations.js +1 -1
  460. package/dist/semantics/normalize/structural-declared-body.d.ts +1 -1
  461. package/dist/semantics/normalize/structural-declared-body.js +1 -1
  462. package/dist/semantics/normalize/structural-generics.d.ts +1 -1
  463. package/dist/semantics/normalize/structural-generics.js +1 -1
  464. package/dist/semantics/normalize/structural-indexed-access.d.ts +1 -1
  465. package/dist/semantics/normalize/structural-indexed-access.js +1 -1
  466. package/dist/semantics/normalize/structural-instantiated-member.d.ts +1 -1
  467. package/dist/semantics/normalize/structural-instantiated-member.js +199 -68
  468. package/dist/semantics/normalize/structural-joins.d.ts +1 -1
  469. package/dist/semantics/normalize/structural-layout-relevance.d.ts +1 -1
  470. package/dist/semantics/normalize/structural-layout-relevance.js +1 -1
  471. package/dist/semantics/normalize/structural-layout-type.d.ts +1 -1
  472. package/dist/semantics/normalize/structural-layout-type.js +14 -2
  473. package/dist/semantics/normalize/structural-leaves.d.ts +1 -1
  474. package/dist/semantics/normalize/structural-leaves.js +1 -1
  475. package/dist/semantics/normalize/structural-local-union.d.ts +1 -1
  476. package/dist/semantics/normalize/structural-local-union.js +21 -16
  477. package/dist/semantics/normalize/structural-members.d.ts +1 -1
  478. package/dist/semantics/normalize/structural-members.js +1 -1
  479. package/dist/semantics/normalize/structural-mutable-field.d.ts +1 -2
  480. package/dist/semantics/normalize/structural-mutable-field.js +17 -4
  481. package/dist/semantics/normalize/structural-mutable-method.d.ts +1 -1
  482. package/dist/semantics/normalize/structural-mutable-method.js +1 -1
  483. package/dist/semantics/normalize/structural-parts.d.ts +1 -1
  484. package/dist/semantics/normalize/structural-parts.js +1 -1
  485. package/dist/semantics/normalize/structural-receiver.d.ts +1 -1
  486. package/dist/semantics/normalize/structural-receiver.js +1 -1
  487. package/dist/semantics/normalize/structural-rules.d.ts +4 -4
  488. package/dist/semantics/normalize/structural-rules.js +30 -12
  489. package/dist/semantics/normalize/structural-self-reference.d.ts +1 -1
  490. package/dist/semantics/normalize/structural-self-reference.js +1 -1
  491. package/dist/semantics/normalize/structural.d.ts +1 -1
  492. package/dist/semantics/normalize/structural.js +2467 -2239
  493. package/dist/semantics/normalize/suppressed-write-arms.d.ts +1 -1
  494. package/dist/semantics/normalize/suppressed-write-arms.js +1 -1
  495. package/dist/semantics/normalize/symbol-keyed-this-slots.d.ts +1 -1
  496. package/dist/semantics/normalize/symbol-keyed-this-slots.js +1 -1
  497. package/dist/semantics/normalize/unreduced-type-form.d.ts +1 -1
  498. package/dist/semantics/normalize/unreduced-type-form.js +1 -1
  499. package/dist/semantics/normalize/unresolvable-names.d.ts +1 -1
  500. package/dist/semantics/normalize/unresolvable-names.js +1 -1
  501. package/dist/semantics/normalize/unshared-array-result.d.ts +1 -1
  502. package/dist/semantics/normalize/unshared-array-result.js +1 -1
  503. package/dist/semantics/package-sources.d.ts +1 -1
  504. package/dist/semantics/package-sources.js +1 -1
  505. package/dist/semantics/program.d.ts +1 -1
  506. package/dist/semantics/program.js +11 -5
  507. package/dist/semantics/prototype-install-source-transform.js +1 -1
  508. package/dist/semantics/prototype-object-class-source-transform.js +1 -1
  509. package/dist/semantics/prototype-reparenting.d.ts +1 -1
  510. package/dist/semantics/prototype-reparenting.js +1 -1
  511. package/dist/semantics/shared-declaration-files.d.ts +1 -1
  512. package/dist/semantics/source-transform-exports.js +1 -1
  513. package/dist/semantics/stable-checker.d.ts +9 -1
  514. package/dist/semantics/stable-checker.js +21 -5
  515. package/dist/semantics/subclass-member-overlay-transform.js +46 -5
  516. package/dist/semantics/symbol-keyed-expando-source-transform.js +1 -1
  517. package/dist/semantics/this-constructor-source-transform.js +1 -1
  518. package/dist/semantics/typescript.d.ts +12 -0
  519. package/dist/semantics/typescript.js +12 -0
  520. package/dist/semantics/uncached-jsdoc-tags.d.ts +16 -0
  521. package/dist/semantics/uncached-jsdoc-tags.js +23 -0
  522. package/dist/semantics/unchecked-guard-argument-copies.d.ts +1 -1
  523. package/dist/semantics/unchecked-guard-argument-copies.js +1 -1
  524. package/dist/semantics/unchecked-write-member-declarations.d.ts +1 -1
  525. package/dist/semantics/unchecked-write-member-declarations.js +1 -1
  526. package/dist/semantics/uninstantiable-classes.d.ts +1 -1
  527. package/dist/semantics/uninstantiable-classes.js +1 -1
  528. package/dist/targets/cpp/conversions.js +137 -87
  529. package/dist/targets/cpp/emit-in.js +2 -1
  530. package/dist/targets/cpp/emit-iterator.d.ts +6 -5
  531. package/dist/targets/cpp/emit-iterator.js +23 -13
  532. package/dist/targets/cpp/emit-narrowing.d.ts +8 -0
  533. package/dist/targets/cpp/emit-narrowing.js +11 -1
  534. package/dist/targets/cpp/emit-record-view.d.ts +9 -0
  535. package/dist/targets/cpp/emit-record-view.js +12 -1
  536. package/package.json +7 -1
@@ -1,4 +1,4 @@
1
- import ts from 'typescript';
1
+ import ts from '#typescript';
2
2
  export const emptyInstantiatedMembers = { through: () => null };
3
3
  /** How deep the pairing walk goes before it stops. A member type nested past this is not worth a table entry. */
4
4
  const pairingDepth = 6;
@@ -10,6 +10,12 @@ const memberNameOf = (member) => {
10
10
  return name.text;
11
11
  return null;
12
12
  };
13
+ const isDefaultLibraryReference = (reference) => {
14
+ if ((reference.objectFlags & ts.ObjectFlags.Reference) === 0)
15
+ return false;
16
+ const declarations = reference.target.getSymbol()?.declarations ?? [];
17
+ return declarations.length > 0 && declarations.every((declaration) => declaration.getSourceFile().hasNoDefaultLib);
18
+ };
13
19
  const isStatic = (member) => ts.canHaveModifiers(member) && (ts.getModifiers(member)?.some((modifier) => modifier.kind === ts.SyntaxKind.StaticKeyword) ?? false);
14
20
  /**
15
21
  * The declarations whose types this table pairs: the members a generic
@@ -34,6 +40,7 @@ export const createInstantiatedMembers = (checker, specializations) => {
34
40
  // so the miss is paid once.
35
41
  const tables = new Map();
36
42
  // The tables of copies with an `any` filling, where an `any` image is real.
43
+ const noneBound = new Set();
37
44
  const anyFilledTables = new WeakSet();
38
45
  /** How many instantiable types `isOpen` has handed to `isCopyHole`; see `isOpenFor`. */
39
46
  let holesAsked = 0;
@@ -54,7 +61,7 @@ export const createInstantiatedMembers = (checker, specializations) => {
54
61
  * A closed type needs no image: it already IS its own instantiation, and the
55
62
  * table exists only to answer for the ones that are not.
56
63
  */
57
- const isOpen = (type, depth, seen, owner) => {
64
+ const isOpen = (type, depth, seen, owner, bound = noneBound) => {
58
65
  // `Instantiable` is the checker's own name for exactly this: a type
59
66
  // parameter, a conditional, an indexed access, a `keyof`, a substitution
60
67
  // or a template-literal mapping -- every form that is unresolved only
@@ -62,7 +69,7 @@ export const createInstantiatedMembers = (checker, specializations) => {
62
69
  // though, not in any parameter at all: see `isCopyHole`.
63
70
  if (type.flags & ts.TypeFlags.Instantiable) {
64
71
  holesAsked++;
65
- return isCopyHole(type, owner, depth);
72
+ return isCopyHole(type, owner, depth, bound);
66
73
  }
67
74
  // A primitive, a literal or an enum member has no structure to hold a
68
75
  // hole and no image other than itself. Its apparent members are the
@@ -76,35 +83,132 @@ export const createInstantiatedMembers = (checker, specializations) => {
76
83
  return false;
77
84
  seen.add(type);
78
85
  if (type.isUnionOrIntersection())
79
- return type.types.some((one) => isOpen(one, depth + 1, seen, owner));
86
+ return type.types.some((one) => isOpen(one, depth + 1, seen, owner, bound));
80
87
  for (const argument of type.aliasTypeArguments ?? [])
81
- if (isOpen(argument, depth + 1, seen, owner))
88
+ if (isOpen(argument, depth + 1, seen, owner, bound))
82
89
  return true;
83
90
  const reference = type;
84
91
  if (reference.target !== undefined) {
85
- for (const argument of checker.getTypeArguments(reference))
86
- if (isOpen(argument, depth + 1, seen, owner))
87
- return true;
92
+ // An instantiated anonymous type (`typeof lookup<R, T>`) has a `target`
93
+ // too, but no type arguments: the checker's `getTypeArguments` reads
94
+ // a reference's own and throws on anything else.
95
+ if (reference.objectFlags & ts.ObjectFlags.Reference)
96
+ for (const argument of checker.getTypeArguments(reference))
97
+ if (isOpen(argument, depth + 1, seen, owner, bound))
98
+ return true;
99
+ if (closedReference(reference, owner))
100
+ return false;
101
+ // The members left can name a hole only as a parameter of a generic
102
+ // function between the declaration and the copy -- the method the copy
103
+ // is of, or one holding it -- and a member's signature binds its own
104
+ // parameters (see the signature walk below), so none names them freely.
105
+ // Reading the members to confirm resolved every one of each instance --
106
+ // `number[]`, `Track[]`, every `U[]` a `map` returns -- for an answer
107
+ // that was always closed.
108
+ if (onlyEnclosingMembersCanBeOpen(reference))
109
+ return false;
110
+ }
111
+ else if (type.isClassOrInterface()) {
112
+ // A class or interface that is not a reference has no parameters of its
113
+ // own and none from outside (the checker makes one nested in a generic
114
+ // function a reference over those), so the same rule holds.
115
+ const declarations = type.getSymbol()?.declarations ?? [];
116
+ if (declarations.length > 0 && !declarations.some((declaration) => encloses(declaration, owner)))
117
+ return false;
118
+ if (declarations.length > 0 && !genericFunctionBetween(owner, declarations))
119
+ return false;
88
120
  }
89
121
  for (const property of type.getProperties()) {
90
122
  const at = property.valueDeclaration ?? property.declarations?.[0];
91
- if (at && isOpen(checker.getTypeOfSymbolAtLocation(property, at), depth + 1, seen, owner))
123
+ if (at && isOpen(checker.getTypeOfSymbolAtLocation(property, at), depth + 1, seen, owner, bound))
92
124
  return true;
93
125
  }
94
126
  for (const index of checker.getIndexInfosOfType(type))
95
- if (isOpen(index.type, depth + 1, seen, owner))
127
+ if (isOpen(index.type, depth + 1, seen, owner, bound))
96
128
  return true;
97
129
  for (const signature of [...type.getCallSignatures(), ...type.getConstructSignatures()]) {
98
- if (isOpen(signature.getReturnType(), depth + 1, seen, owner))
130
+ // A generic signature's own parameters are bound by it, not holes of
131
+ // the copy, even when the copy is of that very declaration: inside
132
+ // `Array.prototype.map<U>`'s copy, `number[]` names `map`'s `U` only
133
+ // through its own `map` member, which every instantiation leaves
134
+ // generic. Counting it made every array type, and every record holding
135
+ // one, an open key of `map`'s copies that no walk could ever record --
136
+ // and each such question ran the copy's whole table. Under a binder the
137
+ // walk sees types in a different light, so it keeps its own `seen`.
138
+ const own = signature.getTypeParameters() ?? [];
139
+ const inner = own.length === 0 ? bound : new Set([...bound, ...own]);
140
+ const innerSeen = own.length === 0 ? seen : new Set();
141
+ if (isOpen(signature.getReturnType(), depth + 1, innerSeen, owner, inner))
99
142
  return true;
100
143
  for (const parameter of signature.parameters) {
101
144
  const at = parameter.valueDeclaration ?? parameter.declarations?.[0];
102
- if (at && isOpen(checker.getTypeOfSymbolAtLocation(parameter, at), depth + 1, seen, owner))
145
+ if (at && isOpen(checker.getTypeOfSymbolAtLocation(parameter, at), depth + 1, innerSeen, owner, inner))
103
146
  return true;
104
147
  }
105
148
  }
106
149
  return false;
107
150
  };
151
+ /**
152
+ * Whether a class, interface or tuple reference whose arguments are all
153
+ * closed is closed itself, without reading its members.
154
+ *
155
+ * Its members can mention only the parameters its arguments fill -- outer
156
+ * parameters of a declaration nested in a generic function among them --
157
+ * and parameters of its own methods. A method's parameter is a hole of this
158
+ * copy only when the copy sits inside that method, which needs the
159
+ * reference's own declaration to enclose the copy. Anywhere else the walk
160
+ * below could find nothing, yet reading the members of `Array<Row>`,
161
+ * `Promise<Session>` and every other closed instantiation the members
162
+ * mention made the checker instantiate each of them, six levels down, for
163
+ * an answer the arguments already gave.
164
+ */
165
+ const closedReference = (reference, owner) => {
166
+ if ((reference.objectFlags & ts.ObjectFlags.Reference) === 0)
167
+ return false;
168
+ const declarations = reference.target.getSymbol()?.declarations;
169
+ if (declarations === undefined)
170
+ return true;
171
+ for (let ancestor = owner; ancestor !== undefined; ancestor = ancestor.parent)
172
+ if (declarations.includes(ancestor))
173
+ return false;
174
+ return true;
175
+ };
176
+ /**
177
+ * Whether, of a reference whose declaration encloses the copy (one
178
+ * `closedReference` could not settle), only the members enclosing the copy
179
+ * can name a hole. Its arguments are already walked, so what is left is a
180
+ * parameter of a method the copy sits in -- in scope in that method alone --
181
+ * or of a function enclosing the declaration itself. With no such function,
182
+ * every other member is closed, and reading them all made a method's copy
183
+ * instantiate its whole class, member by member, six levels down: 6.9
184
+ * million member reads on a large app, most of the checker's growth.
185
+ */
186
+ const onlyEnclosingMembersCanBeOpen = (reference) => {
187
+ // An instantiated mapped or anonymous type also has a `target`, but its
188
+ // holes live in its mapper, not in arguments the walk above has read.
189
+ if ((reference.objectFlags & ts.ObjectFlags.Reference) === 0)
190
+ return false;
191
+ const declarations = reference.target.getSymbol()?.declarations ?? [];
192
+ return (declarations.length > 0 &&
193
+ declarations.every((declaration) => {
194
+ for (let ancestor = declaration.parent; ancestor !== undefined; ancestor = ancestor.parent)
195
+ if (ts.isFunctionLike(ancestor))
196
+ return false;
197
+ return true;
198
+ }));
199
+ };
200
+ const genericFunctionBetween = (owner, declarations) => {
201
+ for (let ancestor = owner; ancestor !== undefined && !declarations.includes(ancestor); ancestor = ancestor.parent)
202
+ if (ts.isFunctionLike(ancestor) && (ancestor.typeParameters?.length ?? 0) > 0)
203
+ return true;
204
+ return false;
205
+ };
206
+ const encloses = (declaration, owner) => {
207
+ for (let ancestor = owner; ancestor !== undefined; ancestor = ancestor.parent)
208
+ if (ancestor === declaration)
209
+ return true;
210
+ return false;
211
+ };
108
212
  /**
109
213
  * Whether an instantiable type is gated on a parameter THIS copy fills.
110
214
  *
@@ -124,7 +228,12 @@ export const createInstantiatedMembers = (checker, specializations) => {
124
228
  * to the parameters they are gated on; a form this does not know stays
125
229
  * open, which is the old answer and the safe one.
126
230
  */
127
- const isCopyHole = (type, owner, depth) => {
231
+ const isCopyHole = (type, owner, depth, bound) => {
232
+ // Bound is an answer, not a guess, so it comes before the depth cap's
233
+ // conservative one: `number[].map`'s `U[]` has a `map` of its own, and
234
+ // the chain of them reached the cap on parameters every link had bound.
235
+ if (bound.has(type))
236
+ return false;
128
237
  if (depth > pairingDepth)
129
238
  return true;
130
239
  const flags = type.flags;
@@ -132,22 +241,22 @@ export const createInstantiatedMembers = (checker, specializations) => {
132
241
  return parameterBelongsToCopy(type, owner);
133
242
  if (flags & ts.TypeFlags.IndexedAccess) {
134
243
  const access = type;
135
- return isCopyHole(access.objectType, owner, depth + 1) || isCopyHole(access.indexType, owner, depth + 1);
244
+ return isCopyHole(access.objectType, owner, depth + 1, bound) || isCopyHole(access.indexType, owner, depth + 1, bound);
136
245
  }
137
246
  if (flags & ts.TypeFlags.Conditional) {
138
247
  const conditional = type;
139
- return isCopyHole(conditional.checkType, owner, depth + 1) || isCopyHole(conditional.extendsType, owner, depth + 1);
248
+ return isCopyHole(conditional.checkType, owner, depth + 1, bound) || isCopyHole(conditional.extendsType, owner, depth + 1, bound);
140
249
  }
141
250
  if (flags & ts.TypeFlags.Index)
142
- return isCopyHole(type.type, owner, depth + 1);
251
+ return isCopyHole(type.type, owner, depth + 1, bound);
143
252
  if (flags & ts.TypeFlags.StringMapping)
144
- return isCopyHole(type.type, owner, depth + 1);
253
+ return isCopyHole(type.type, owner, depth + 1, bound);
145
254
  if (flags & ts.TypeFlags.Substitution)
146
- return isCopyHole(type.baseType, owner, depth + 1);
255
+ return isCopyHole(type.baseType, owner, depth + 1, bound);
147
256
  if (flags & ts.TypeFlags.TemplateLiteral)
148
- return type.types.some((one) => isCopyHole(one, owner, depth + 1));
257
+ return type.types.some((one) => isCopyHole(one, owner, depth + 1, bound));
149
258
  if (type.isUnionOrIntersection())
150
- return type.types.some((one) => isCopyHole(one, owner, depth + 1));
259
+ return type.types.some((one) => isCopyHole(one, owner, depth + 1, bound));
151
260
  return (flags & ts.TypeFlags.Instantiable) !== 0;
152
261
  };
153
262
  /**
@@ -222,7 +331,7 @@ export const createInstantiatedMembers = (checker, specializations) => {
222
331
  return true;
223
332
  return false;
224
333
  };
225
- const pair = (open, closed, into, depth, seen, owner) => {
334
+ function* pair(open, closed, into, depth, seen, owner) {
226
335
  if (open === closed || !admits(open, into, depth, owner))
227
336
  return;
228
337
  // The open side is admitted because it has a genuine hole (`admits` already
@@ -252,6 +361,7 @@ export const createInstantiatedMembers = (checker, specializations) => {
252
361
  if ((closed.flags & ts.TypeFlags.Any) !== 0 && !anyFilledTables.has(into))
253
362
  return;
254
363
  into.set(open, closed);
364
+ yield;
255
365
  // A deferred CONDITIONAL is recorded whole and never walked into. Its
256
366
  // properties and signatures are the checker's apparent ones, synthesized
257
367
  // from its constraint rather than declared -- `Parameters<E[K]>` answers
@@ -283,11 +393,11 @@ export const createInstantiatedMembers = (checker, specializations) => {
283
393
  // lost by stopping here.
284
394
  if (open.isUnion() || closed.isUnion()) {
285
395
  if (open.isUnion() && closed.isUnion())
286
- pairArms(open.types, closed.types, into, depth, seen, owner);
396
+ yield* pairArms(open.types, closed.types, into, depth, seen, owner);
287
397
  return;
288
398
  }
289
399
  if (open.isIntersection() && closed.isIntersection())
290
- pairArms(open.types, closed.types, into, depth, seen, owner);
400
+ yield* pairArms(open.types, closed.types, into, depth, seen, owner);
291
401
  // The ARGUMENTS of a reference, so `Promise<Keyed<T>>` records an
292
402
  // entry for `Keyed<T>` too. The target is checked, not just the
293
403
  // count: two references of the same arity to different generics have
@@ -303,9 +413,18 @@ export const createInstantiatedMembers = (checker, specializations) => {
303
413
  const one = openArguments[index];
304
414
  const other = closedArguments[index];
305
415
  if (one && other)
306
- pair(one, other, into, depth + 1, seen, owner);
416
+ yield* pair(one, other, into, depth + 1, seen, owner);
307
417
  }
308
418
  }
419
+ // A default-library generic (`Array`, `Map`, `Promise`, the iterators)
420
+ // is its arguments: every member is the declared member instantiated
421
+ // with them, which `structural.ts` translates part by part once the
422
+ // arguments above have images. Walking the members anyway paired each
423
+ // method of `U[]` against `Item[]` six levels deep -- 553 of the 556
424
+ // entries in each of 165 copies of `Array.prototype.map` on a 48K-line
425
+ // app, never asked, and 300 MB of instantiations the checker keeps.
426
+ if (isDefaultLibraryReference(openReference))
427
+ return;
309
428
  }
310
429
  // Members BY NAME. A record's own fields are where the remaining holes sit
311
430
  // once the signature positions are paired -- a `Query<T>` that is a mapped
@@ -322,7 +441,7 @@ export const createInstantiatedMembers = (checker, specializations) => {
322
441
  const counterpart = checker.getPropertyOfType(closed, property.getName());
323
442
  if (!counterpart)
324
443
  continue;
325
- pair(openMember, checker.getTypeOfSymbolAtLocation(counterpart, at), into, depth + 1, seen, owner);
444
+ yield* pair(openMember, checker.getTypeOfSymbolAtLocation(counterpart, at), into, depth + 1, seen, owner);
326
445
  }
327
446
  // Index signatures BY KEY TYPE, the same exact correspondence a name is:
328
447
  // `Result<T>.ids` typed `{ [key: number]: InferId<T> }` has its only hole
@@ -333,11 +452,11 @@ export const createInstantiatedMembers = (checker, specializations) => {
333
452
  for (const index of checker.getIndexInfosOfType(open)) {
334
453
  const counterpart = closedIndexes.find((candidate) => candidate.keyType === index.keyType);
335
454
  if (counterpart && admits(index.type, into, depth + 1, owner))
336
- pair(index.type, counterpart.type, into, depth + 1, seen, owner);
455
+ yield* pair(index.type, counterpart.type, into, depth + 1, seen, owner);
337
456
  }
338
- pairSignatures(open.getCallSignatures(), closed.getCallSignatures(), into, depth, seen, owner);
339
- pairSignatures(open.getConstructSignatures(), closed.getConstructSignatures(), into, depth, seen, owner);
340
- };
457
+ yield* pairSignatures(open.getCallSignatures(), closed.getCallSignatures(), into, depth, seen, owner);
458
+ yield* pairSignatures(open.getConstructSignatures(), closed.getConstructSignatures(), into, depth, seen, owner);
459
+ }
341
460
  /**
342
461
  * A union's arms, matched by IDENTITY and then by elimination -- never by
343
462
  * position.
@@ -360,9 +479,9 @@ export const createInstantiatedMembers = (checker, specializations) => {
360
479
  * unambiguous, so that is the only case that records anything; anything else
361
480
  * is a collapse or a genuine ambiguity, and the honest answer is no entry.
362
481
  */
363
- const pairArms = (open, closed, into, depth, seen, owner) => {
482
+ function* pairArms(open, closed, into, depth, seen, owner) {
364
483
  const remaining = [...closed];
365
- let unmatched = [];
484
+ const unmatched = [];
366
485
  for (const arm of open) {
367
486
  const at = remaining.indexOf(arm);
368
487
  if (at >= 0)
@@ -376,25 +495,25 @@ export const createInstantiatedMembers = (checker, specializations) => {
376
495
  // which leaves `Omit<T, 'key'>` and its `Pick<...>` image as the
377
496
  // one-to-one leftover. Two arms of one generic (`ArrayIterator<A> |
378
497
  // ArrayIterator<B>`) share a symbol and so are never matched this way.
379
- unmatched = unmatched.filter((arm) => {
498
+ const leftover = [];
499
+ for (const arm of unmatched) {
380
500
  const symbol = arm.getSymbol();
381
- if (!symbol)
382
- return true;
383
- const candidates = remaining.filter((candidate) => candidate.getSymbol() === symbol);
384
- const rivals = unmatched.filter((other) => other.getSymbol() === symbol);
501
+ const candidates = symbol ? remaining.filter((candidate) => candidate.getSymbol() === symbol) : [];
502
+ const rivals = symbol ? unmatched.filter((other) => other.getSymbol() === symbol) : [];
385
503
  const image = candidates.length === 1 && rivals.length === 1 ? candidates[0] : undefined;
386
- if (!image)
387
- return true;
504
+ if (!image) {
505
+ leftover.push(arm);
506
+ continue;
507
+ }
388
508
  remaining.splice(remaining.indexOf(image), 1);
389
- pair(arm, image, into, depth + 1, seen, owner);
390
- return false;
391
- });
392
- const sole = unmatched.length === 1 ? unmatched[0] : undefined;
509
+ yield* pair(arm, image, into, depth + 1, seen, owner);
510
+ }
511
+ const sole = leftover.length === 1 ? leftover[0] : undefined;
393
512
  const image = remaining.length === 1 ? remaining[0] : undefined;
394
513
  if (sole && image)
395
- pair(sole, image, into, depth + 1, seen, owner);
396
- };
397
- const pairSignatures = (open, closed, into, depth, seen, owner) => {
514
+ yield* pair(sole, image, into, depth + 1, seen, owner);
515
+ }
516
+ function* pairSignatures(open, closed, into, depth, seen, owner) {
398
517
  if (open.length !== closed.length)
399
518
  return;
400
519
  for (let index = 0; index < open.length; index += 1) {
@@ -404,7 +523,7 @@ export const createInstantiatedMembers = (checker, specializations) => {
404
523
  continue;
405
524
  const openReturn = left.getReturnType();
406
525
  if (admits(openReturn, into, depth + 1, owner))
407
- pair(openReturn, right.getReturnType(), into, depth + 1, seen, owner);
526
+ yield* pair(openReturn, right.getReturnType(), into, depth + 1, seen, owner);
408
527
  if (left.parameters.length !== right.parameters.length)
409
528
  continue;
410
529
  for (let position = 0; position < left.parameters.length; position += 1) {
@@ -416,10 +535,10 @@ export const createInstantiatedMembers = (checker, specializations) => {
416
535
  const openParameter = checker.getTypeOfSymbolAtLocation(leftParameter, at);
417
536
  if (!admits(openParameter, into, depth + 1, owner))
418
537
  continue;
419
- pair(openParameter, checker.getTypeOfSymbolAtLocation(rightParameter, at), into, depth + 1, seen, owner);
538
+ yield* pair(openParameter, checker.getTypeOfSymbolAtLocation(rightParameter, at), into, depth + 1, seen, owner);
420
539
  }
421
540
  }
422
- };
541
+ }
423
542
  const build = (declaration, ordinal) => {
424
543
  const copy = specializations.specializationsOf(declaration)[ordinal];
425
544
  if (!copy)
@@ -431,26 +550,37 @@ export const createInstantiatedMembers = (checker, specializations) => {
431
550
  const table = new Map();
432
551
  if (copy.arguments.some((argument) => (argument.flags & ts.TypeFlags.Any) !== 0))
433
552
  anyFilledTables.add(table);
434
- if (signatures)
435
- pairSignatures([signatures[0]], [signatures[1]], table, 0, new Set(), declaration);
436
- if (!closedParent)
437
- return table;
438
- for (const member of membersOf(declaration)) {
439
- const name = memberNameOf(member);
440
- if (name === null)
441
- continue;
442
- const openSymbol = checker.getSymbolAtLocation(member.name);
443
- if (!openSymbol)
444
- continue;
445
- const openMember = checker.getTypeOfSymbolAtLocation(openSymbol, member);
446
- if (!admits(openMember, table, 0, declaration))
447
- continue;
448
- const closedSymbol = checker.getPropertyOfType(closedParent, name);
449
- if (!closedSymbol)
450
- continue;
451
- pair(openMember, checker.getTypeOfSymbolAtLocation(closedSymbol, member), table, 0, new Set(), declaration);
553
+ function* walk() {
554
+ if (signatures)
555
+ yield* pairSignatures([signatures[0]], [signatures[1]], table, 0, new Set(), declaration);
556
+ if (!closedParent)
557
+ return;
558
+ for (const member of membersOf(declaration)) {
559
+ const name = memberNameOf(member);
560
+ if (name === null)
561
+ continue;
562
+ const openSymbol = checker.getSymbolAtLocation(member.name);
563
+ if (!openSymbol)
564
+ continue;
565
+ const openMember = checker.getTypeOfSymbolAtLocation(openSymbol, member);
566
+ if (!admits(openMember, table, 0, declaration))
567
+ continue;
568
+ const closedSymbol = checker.getPropertyOfType(closedParent, name);
569
+ if (!closedSymbol)
570
+ continue;
571
+ yield* pair(openMember, checker.getTypeOfSymbolAtLocation(closedSymbol, member), table, 0, new Set(), declaration);
572
+ }
452
573
  }
453
- return table;
574
+ return { entries: table, owner: declaration, steps: walk(), done: false };
575
+ };
576
+ const answerIn = (table, type) => {
577
+ // The walk records only types `admits`, so a closed one is never a key.
578
+ if (!isOpenFor(type, table.owner))
579
+ return undefined;
580
+ while (!table.done && !table.entries.has(type))
581
+ if (table.steps.next().done)
582
+ table.done = true;
583
+ return table.entries.get(type);
454
584
  };
455
585
  const tableFor = (declaration, ordinal) => {
456
586
  const known = tables.get(declaration) ?? [];
@@ -475,7 +605,8 @@ export const createInstantiatedMembers = (checker, specializations) => {
475
605
  const step = path[index];
476
606
  if (!step)
477
607
  continue;
478
- const answer = tableFor(step.owner, step.ordinal)?.get(type);
608
+ const table = tableFor(step.owner, step.ordinal);
609
+ const answer = table && answerIn(table, type);
479
610
  if (answer)
480
611
  return answer;
481
612
  }
@@ -1,4 +1,4 @@
1
- import ts from 'typescript';
1
+ import ts from '#typescript';
2
2
  import type { StructuralTypeId } from '../../identity/ids.js';
3
3
  import type { StructuralTypeTable } from '../model/structural-type-table.js';
4
4
  /**
@@ -1,4 +1,4 @@
1
- import ts from 'typescript';
1
+ import ts from '#typescript';
2
2
  export declare const layoutRelevantParameterIndices: (checker: ts.TypeChecker, declaration: ts.ClassLikeDeclaration | ts.InterfaceDeclaration) => ReadonlySet<number>;
3
3
  /**
4
4
  * The parameter positions this class keeps in MUTABLE storage of its own.
@@ -1,4 +1,4 @@
1
- import ts from 'typescript';
1
+ import ts from '#typescript';
2
2
  /**
3
3
  * Which of a generic class or interface's own type parameters actually reach
4
4
  * a STORED value.
@@ -1,4 +1,4 @@
1
- import ts from 'typescript';
1
+ import ts from '#typescript';
2
2
  import { type AbsentGlobalCensus } from './absent-globals.js';
3
3
  import { type ParameterBindingCensus } from './parameter-bindings.js';
4
4
  /**
@@ -1,10 +1,12 @@
1
1
  import { annotationStatesNothing, censusedTypeAt, arrayFromCopyTypeAt, containsUnstatedPosition, narrowsOnlyUnstatedPositions, singleConventionAt, impliedPatternElementRootOf, impliedPatternParameterOf, impliedPatternTargetOf, isGlobalObjectMember, objectAssignFreshTargetType, objectAssignTargetType, nominalConstructorChoiceTypeAt } from './derived-expression-type.js';
2
2
  import { isUnreducedTypeForm } from './unreduced-type-form.js';
3
- import ts from 'typescript';
3
+ import ts from '#typescript';
4
4
  import { inheritedImplementationOf } from './merged-declaration.js';
5
5
  import { emptyAbsentGlobalCensus } from './absent-globals.js';
6
6
  import { emptyParameterBindingCensus } from './parameter-bindings.js';
7
7
  import { unsharedArrayResultBodyOf } from './unshared-array-result.js';
8
+ import { memoizedTypeAt } from '../stable-checker.js';
9
+ import { KeySet } from './nullable-memo.js';
8
10
  /**
9
11
  * Which type an object or array literal is laid out as.
10
12
  *
@@ -1717,19 +1719,29 @@ export const createLayoutTypeResolver = (checker, parameters = emptyParameterBin
1717
1719
  };
1718
1720
  // A resolver closes over one checker and one census snapshot. Reusing an
1719
1721
  // answer here cannot cross binding-fixpoint rounds or checker lifetimes.
1722
+ //
1723
+ // An answer that is the checker's own memoized type for the node -- 98% of
1724
+ // them on a 48K-line app, 230K nodes held for the rest of the compile -- is
1725
+ // a bit here rather than a second copy of that memo's entry.
1720
1726
  const answers = new WeakMap();
1727
+ const checkerAnswers = new KeySet();
1721
1728
  const layoutTypeAt = (node) => {
1722
1729
  // The frontend seals intrinsic obligations after its host census. A
1723
1730
  // pre-seal `any` memo cannot outrank a later authenticated native alias.
1724
1731
  const nativeClassAlias = nativeClassAliasTypeAt?.(node);
1725
1732
  if (nativeClassAlias)
1726
1733
  return nativeClassAlias;
1734
+ if (checkerAnswers.has(node))
1735
+ return checker.getTypeAtLocation(node);
1727
1736
  const known = answers.get(node);
1728
1737
  if (known)
1729
1738
  return known;
1730
1739
  const answer = layoutTypeOf(node);
1731
1740
  const selected = armsLiveUnderMemberNarrowing(node, answer) ?? answer;
1732
- answers.set(node, selected);
1741
+ if (selected === memoizedTypeAt(checker, node))
1742
+ checkerAnswers.add(node);
1743
+ else
1744
+ answers.set(node, selected);
1733
1745
  return selected;
1734
1746
  };
1735
1747
  return layoutTypeAt;
@@ -1,4 +1,4 @@
1
- import ts from 'typescript';
1
+ import ts from '#typescript';
2
2
  import type { PropertyKeyShape, StructuralShape } from '../model/structural-types.js';
3
3
  import type { IdentityTable } from './identities.js';
4
4
  /**
@@ -1,4 +1,4 @@
1
- import ts from 'typescript';
1
+ import ts from '#typescript';
2
2
  import { privateNameKeyText } from '../model/structural-types.js';
3
3
  /**
4
4
  * A `ts.Type` that is a leaf: it maps straight to its shape with no walk.
@@ -1,4 +1,4 @@
1
- import ts from 'typescript';
1
+ import ts from '#typescript';
2
2
  import type { StructuralTypeId } from '../../identity/ids.js';
3
3
  import type { StructuralTypeTable } from '../model/structural-type-table.js';
4
4
  import type { ValueFlowIndex } from './flow/model.js';
@@ -1,4 +1,4 @@
1
- import ts from 'typescript';
1
+ import ts from '#typescript';
2
2
  import { containsUnstatedPosition } from './derived-expression-type.js';
3
3
  /**
4
4
  * Complete a synthesized local union in the SAME specialization view as its
@@ -8,10 +8,13 @@ import { containsUnstatedPosition } from './derived-expression-type.js';
8
8
  * back to Function. The flow index supplies every write, never a syntax scan.
9
9
  */
10
10
  export const createLocalUnionResolver = (checker, table, census, flow, read, refinedSourceAt = () => null, sourceCallResultAt = () => null) => {
11
- const memo = new Map();
12
- const pending = new Set();
13
- const sourceRefined = new Set();
14
- const sourceCallRefined = new Set();
11
+ // Created on first use: one resolver is built per structural view (907 on
12
+ // a 48K-line app) and most never resolve a local, so four empty hash tables
13
+ // per view were held for the whole compile.
14
+ let memo;
15
+ let pending;
16
+ let sourceRefined;
17
+ let sourceCallRefined;
15
18
  const localOf = (node) => {
16
19
  if (!ts.isIdentifier(node))
17
20
  return null;
@@ -35,15 +38,16 @@ export const createLocalUnionResolver = (checker, table, census, flow, read, ref
35
38
  const resolve = (declaration) => {
36
39
  if (!flow || declaration.type || !ts.isIdentifier(declaration.name))
37
40
  return null;
38
- if (memo.has(declaration))
41
+ if (memo?.has(declaration))
39
42
  return memo.get(declaration) ?? null;
40
- if (pending.has(declaration))
43
+ if (pending?.has(declaration))
41
44
  return null;
42
45
  const writes = flow.writesToDeclaration(declaration).filter((write) => write.slot === 'whole');
43
46
  if (!writes.length ||
44
47
  writes.some((write) => !write.value || (write.edge !== 'declaration-initializer' && write.edge !== 'identifier-assignment')))
45
48
  return null;
46
- pending.add(declaration);
49
+ const inFlight = (pending ??= new Set());
50
+ inFlight.add(declaration);
47
51
  // A proved own Function replacement can have a different result from the
48
52
  // checker's inherited .call signature. It owns this writer's value; every
49
53
  // other writer still contributes its actual structural type. An inferred
@@ -55,7 +59,7 @@ export const createLocalUnionResolver = (checker, table, census, flow, read, ref
55
59
  return direct;
56
60
  const alias = localOf(value);
57
61
  const result = alias ? resolve(alias) : null;
58
- return alias && sourceCallRefined.has(alias) ? result : null;
62
+ return alias && sourceCallRefined?.has(alias) ? result : null;
59
63
  });
60
64
  const hasSourceCall = sourceCalls.some((result) => result !== null);
61
65
  const unionArms = census.unionArmsAt(declaration);
@@ -66,20 +70,21 @@ export const createLocalUnionResolver = (checker, table, census, flow, read, ref
66
70
  const refinements = writes.map((write) => refinedSourceAt(write.value));
67
71
  const first = refinements[0];
68
72
  if (!first || refinements.some((id) => id !== first) || !concreteRefinement(first)) {
69
- pending.delete(declaration);
73
+ inFlight.delete(declaration);
70
74
  return null;
71
75
  }
72
- sourceRefined.add(declaration);
76
+ ;
77
+ (sourceRefined ??= new Set()).add(declaration);
73
78
  }
74
79
  if (hasSourceCall)
75
- sourceCallRefined.add(declaration);
80
+ (sourceCallRefined ??= new Set()).add(declaration);
76
81
  const members = writes.map((write, ordinal) => sourceCalls[ordinal] ?? read(write.value));
77
- pending.delete(declaration);
82
+ inFlight.delete(declaration);
78
83
  // An uninitialized lexical binding holds undefined until its first write.
79
84
  if (!declaration.initializer)
80
85
  members.push(table.intern({ kind: 'primitive', primitive: 'undefined' }));
81
86
  const result = table.intern({ kind: 'union', members });
82
- memo.set(declaration, result);
87
+ (memo ??= new Map()).set(declaration, result);
83
88
  return result;
84
89
  };
85
90
  return (node) => {
@@ -100,7 +105,7 @@ export const createLocalUnionResolver = (checker, table, census, flow, read, ref
100
105
  // The checker inferred these locals from a different executable source.
101
106
  // Even its nullish exclusions may be stale. Preserve the complete actual
102
107
  // writer domain; later control-flow proofs may narrow that native value.
103
- if (sourceCallRefined.has(declaration))
108
+ if (sourceCallRefined?.has(declaration))
104
109
  return result;
105
110
  // Calling a union-held local does not first convert the cell into the
106
111
  // checker's common signature. The callable value remains whichever arm
@@ -131,7 +136,7 @@ export const createLocalUnionResolver = (checker, table, census, flow, read, ref
131
136
  }
132
137
  // A real flow narrowing keeps its own type. An erased Function/any at a
133
138
  // read is not such a narrowing, but may still prove nullish exclusion.
134
- if (!sourceRefined.has(declaration) && !containsUnstatedPosition(checker, node, raw))
139
+ if (!sourceRefined?.has(declaration) && !containsUnstatedPosition(checker, node, raw))
135
140
  return null;
136
141
  if ((raw.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0)
137
142
  return result;
@@ -1,4 +1,4 @@
1
- import ts from 'typescript';
1
+ import ts from '#typescript';
2
2
  import type { IdentityTable } from './identities.js';
3
3
  /**
4
4
  * Which members of an object type a LAYOUT carries.