carrick 0.3.138 → 0.3.139

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.
@@ -245,20 +245,8 @@ function entrySubpaths(manifest) {
245
245
  }
246
246
  return [''];
247
247
  }
248
- /**
249
- * Declaration keys (`file\0declaredName`) of what `file` exports as `name`.
250
- * A chunk can declare a type under its public name and export it under a
251
- * short one (`export { type OmitKeyof as O }`), so the name read off the
252
- * import is not the name the declaration carries.
253
- */
254
- function declarationKeysOfExport(file, name) {
255
- const program = ts.createProgram([file], RESOLUTION_OPTIONS);
256
- const checker = program.getTypeChecker();
257
- const source = program.getSourceFile(file);
258
- const moduleSymbol = source && checker.getSymbolAtLocation(source);
259
- const symbol = moduleSymbol && checker.getExportsOfModule(moduleSymbol).find((s) => s.getName() === name);
260
- if (!symbol)
261
- return [];
248
+ /** Alias chain of an exported symbol followed to the symbol that declares it. */
249
+ function resolveAliasTarget(checker, symbol) {
262
250
  let target = symbol;
263
251
  for (let hops = 0; target.flags & ts.SymbolFlags.Alias && hops < 16; hops++) {
264
252
  const next = checker.getAliasedSymbol(target);
@@ -266,16 +254,41 @@ function declarationKeysOfExport(file, name) {
266
254
  break;
267
255
  target = next;
268
256
  }
269
- const keys = [];
270
- for (const declaration of target.declarations ?? []) {
271
- try {
272
- keys.push(`${fs.realpathSync(declaration.getSourceFile().fileName)}\0${target.getName()}`);
273
- }
274
- catch {
275
- // declaration outside the real file system: ignore
257
+ return target;
258
+ }
259
+ const declarationKeysCache = new Map();
260
+ /**
261
+ * Declaration keys (`file\0declaredName`) of what `file` exports as `name`.
262
+ * A chunk can declare a type under its public name and export it under a
263
+ * short one (`export { type OmitKeyof as O }`), so the name read off the
264
+ * import is not the name the declaration carries. One program per file answers
265
+ * every name asked of it (carrick#3117).
266
+ */
267
+ function declarationKeysOfExport(file, name) {
268
+ let byName = declarationKeysCache.get(file);
269
+ if (!byName) {
270
+ byName = new Map();
271
+ const program = ts.createProgram([file], RESOLUTION_OPTIONS);
272
+ const checker = program.getTypeChecker();
273
+ const source = program.getSourceFile(file);
274
+ const moduleSymbol = source && checker.getSymbolAtLocation(source);
275
+ for (const symbol of moduleSymbol ? checker.getExportsOfModule(moduleSymbol) : []) {
276
+ const target = resolveAliasTarget(checker, symbol);
277
+ const keys = [];
278
+ for (const declaration of target.declarations ?? []) {
279
+ try {
280
+ keys.push(`${fs.realpathSync(declaration.getSourceFile().fileName)}\0${target.getName()}`);
281
+ }
282
+ catch {
283
+ // declaration outside the real file system: ignore
284
+ }
285
+ }
286
+ if (!byName.has(symbol.getName()))
287
+ byName.set(symbol.getName(), keys);
276
288
  }
289
+ declarationKeysCache.set(file, byName);
277
290
  }
278
- return keys;
291
+ return byName.get(name) ?? [];
279
292
  }
280
293
  const moduleExportsCache = new Map();
281
294
  /**
@@ -293,14 +306,8 @@ function exportsOf(entryFile) {
293
306
  const source = program.getSourceFile(entryFile);
294
307
  const moduleSymbol = source && checker.getSymbolAtLocation(source);
295
308
  for (const symbol of moduleSymbol ? checker.getExportsOfModule(moduleSymbol) : []) {
296
- let target = symbol;
297
309
  // Follow the alias chain until it stops (an entry can re-export a re-export).
298
- for (let hops = 0; target.flags & ts.SymbolFlags.Alias && hops < 16; hops++) {
299
- const next = checker.getAliasedSymbol(target);
300
- if (next === target)
301
- break;
302
- target = next;
303
- }
310
+ const target = resolveAliasTarget(checker, symbol);
304
311
  const files = new Set();
305
312
  for (const declaration of target.declarations ?? []) {
306
313
  try {
@@ -35,19 +35,30 @@ import ts from 'typescript';
35
35
  import type { CaptureAliasRecord } from './api.js';
36
36
  import type { ResolvedAnchor } from './anchors.js';
37
37
  import type { WriteGuard } from './guarded-fs.js';
38
+ /** One surface entry of the tree and the anchors its aliases came from. */
39
+ export interface SelfCheckSurface {
40
+ surfaceAbsPath: string;
41
+ resolved: ResolvedAnchor[];
42
+ }
38
43
  export interface SelfCheckArgs {
39
44
  /** Writes are held to the stub (carrick#1748). */
40
45
  guard: WriteGuard;
41
46
  stubDir: string;
42
- surfaceAbsPath: string;
43
- resolved: ResolvedAnchor[];
47
+ /**
48
+ * The surfaces checked over the tree, each with records of its own. Two when
49
+ * a capture's literal backfill holds the same tree as its first surface
50
+ * (carrick#2041): the second sits beside the first, a module nothing
51
+ * imports, so neither changes what the other's aliases read.
52
+ */
53
+ surfaces: SelfCheckSurface[];
44
54
  pinned: Record<string, string>;
45
55
  bareCheckout: boolean;
46
56
  /** Producer repo root; its node_modules (if any) backs resolution. */
47
57
  repoRoot: string;
48
58
  compilerHost?: (options: ts.CompilerOptions) => ts.CompilerHost;
49
59
  }
50
- export declare function selfCheckStub(args: SelfCheckArgs): CaptureAliasRecord[];
60
+ /** The records of each surface, in `args.surfaces` order. */
61
+ export declare function selfCheckStub(args: SelfCheckArgs): CaptureAliasRecord[][];
51
62
  /**
52
63
  * The options of every self-check program.
53
64
  *
@@ -38,6 +38,7 @@ import { sidecarCompilerOptions } from './compiler-options.js';
38
38
  import { collectSpecifiers, declarationCandidates, isDeclarationFileName, isRelative, packageNameOf, } from './specifiers.js';
39
39
  import { repairDanglingImports } from './repair-dangling.js';
40
40
  import { findDisqualifyingTopTypes, findUnresolvedPlaceholders, isErrorPlaceholder, provenanceOf, unemittedModuleProvenance, unresolvedInTreeProvenance, } from './deep-walk.js';
41
+ /** The records of each surface, in `args.surfaces` order. */
41
42
  export function selfCheckStub(args) {
42
43
  const typesDir = path.join(args.stubDir, 'types');
43
44
  const treeFiles = [];
@@ -110,17 +111,26 @@ function runSelfCheck(args, treeFiles, repaired) {
110
111
  const program = ts.createProgram(treeFiles, SELF_CHECK_OPTIONS, args.compilerHost?.(SELF_CHECK_OPTIONS));
111
112
  const checker = program.getTypeChecker();
112
113
  const diagnostics = ts.getPreEmitDiagnostics(program);
113
- const surfaceAbs = path.resolve(args.surfaceAbsPath);
114
- const surfaceSource = program.getSourceFile(surfaceAbs);
115
- // The surface holds EVERY alias, and every alias's closure starts there, so
114
+ // A surface holds EVERY alias, and every alias's closure starts there, so
116
115
  // a file-granular failure bucket on it blames the whole service for one
117
116
  // alias's dangling specifier (cloud#1184). Attribute by `export type`
118
117
  // statement span, exactly as check-poison.ts contains poison.
119
- const aliasAtSurfacePosition = buildSurfaceSpanIndex(surfaceSource);
118
+ const surfaces = args.surfaces.map((surface) => {
119
+ const surfaceAbs = path.resolve(surface.surfaceAbsPath);
120
+ const surfaceSource = program.getSourceFile(surfaceAbs);
121
+ return {
122
+ surfaceAbs,
123
+ surfaceSource,
124
+ resolved: surface.resolved,
125
+ aliasAtSurfacePosition: buildSurfaceSpanIndex(surfaceSource),
126
+ // Failed module specifiers on the surface, per ALIAS.
127
+ surfaceFailuresByAlias: new Map(),
128
+ };
129
+ });
130
+ const surfaceAt = new Map(surfaces.map((surface) => [surface.surfaceAbs, surface]));
120
131
  // Failed module specifiers, split external-pinned vs internal, per FILE —
121
- // except on the surface, where they are per ALIAS.
132
+ // except on a surface, where they are per ALIAS.
122
133
  const failuresByFile = new Map();
123
- const surfaceFailuresByAlias = new Map();
124
134
  const emptyFailures = () => ({
125
135
  externalPinned: new Set(),
126
136
  internal: new Set(),
@@ -139,8 +149,9 @@ function runSelfCheck(args, treeFiles, repaired) {
139
149
  // service-wide file bucket: soundness over precision, the same fallback
140
150
  // check-poison.ts makes.
141
151
  const bucketFor = (abs, start) => {
142
- const owner = abs === surfaceAbs ? aliasAtSurfacePosition(start) : undefined;
143
- return owner ? bucketIn(surfaceFailuresByAlias, owner) : bucketIn(failuresByFile, abs);
152
+ const surface = surfaceAt.get(abs);
153
+ const owner = surface?.aliasAtSurfacePosition(start);
154
+ return surface && owner ? bucketIn(surface.surfaceFailuresByAlias, owner) : bucketIn(failuresByFile, abs);
144
155
  };
145
156
  for (const d of diagnostics) {
146
157
  if (!d.file)
@@ -189,30 +200,27 @@ function runSelfCheck(args, treeFiles, repaired) {
189
200
  }
190
201
  adjacency.set(abs, neighbors);
191
202
  }
192
- const records = [];
193
- for (const anchor of args.resolved) {
194
- // Demotions (failureReason present) never reached the surface with a
195
- // real type; everything else — including successful literal anchors,
196
- // which sit at the structural_fallback TIER but did produce text — is
197
- // classified by the real self-check.
198
- records.push(anchor.failureReason !== undefined
199
- ? demotedRecord(anchor)
200
- : checkedRecord(anchor, {
201
- args,
202
- program,
203
- checker,
204
- surfaceAbs,
205
- surfaceSource,
206
- adjacency,
207
- failuresByFile,
208
- surfaceFailuresByAlias,
209
- }));
210
- }
203
+ // Demotions (failureReason present) never reached the surface with a real
204
+ // type; everything else — including successful literal anchors, which sit
205
+ // at the structural_fallback TIER but did produce text — is classified by
206
+ // the real self-check.
207
+ const records = surfaces.map((surface) => surface.resolved.map((anchor) => anchor.failureReason !== undefined
208
+ ? demotedRecord(anchor)
209
+ : checkedRecord(anchor, {
210
+ args,
211
+ program,
212
+ checker,
213
+ surfaceAbs: surface.surfaceAbs,
214
+ surfaceSource: surface.surfaceSource,
215
+ adjacency,
216
+ failuresByFile,
217
+ surfaceFailuresByAlias: surface.surfaceFailuresByAlias,
218
+ })));
211
219
  const internalFailuresByFile = new Map();
212
220
  for (const [file, failures] of failuresByFile) {
213
- // The surface's own failures are a literal anchor's pasted text
221
+ // A surface's own failures are a literal anchor's pasted text
214
222
  // (carrick#1361), not a declaration with an import to drop.
215
- if (file === surfaceAbs || failures.internal.size === 0)
223
+ if (surfaceAt.has(file) || failures.internal.size === 0)
216
224
  continue;
217
225
  // A file already repaired has had its turn: repairing it again would chase
218
226
  // its own leftover diagnostics.
@@ -33,6 +33,7 @@ import { addProgramFiles, listProgramFiles } from './program-files.js';
33
33
  import { changedSource, inferCacheDir, keepable, programDifference, programRecord, rebuildProgram, readEntry, requestDigest, writeEntry, } from './infer-cache.js';
34
34
  import { writePositionRows } from './position-rows.js';
35
35
  import { findImplementations } from './implementations.js';
36
+ import { importGraphOf, mergeGraphs, reach, serialiseGraph } from './affected-set.js';
36
37
  // ===========================================================================
37
38
  // Module-level state
38
39
  // ===========================================================================
@@ -265,6 +266,8 @@ function handleCaptureV2(request) {
265
266
  outDir: request.out_dir,
266
267
  tsconfigPath: request.tsconfig_path,
267
268
  scanRoot: request.scan_root,
269
+ backfillTexts: request.backfill_texts,
270
+ backfillOutDir: request.backfill_out_dir,
268
271
  onProgress: (phase, message) => {
269
272
  if (phase === stage)
270
273
  return withinStage(phase, message);
@@ -570,6 +573,36 @@ function handleRetypeCheck(request) {
570
573
  return { request_id: request.request_id, status: 'error', errors: [error] };
571
574
  }
572
575
  }
576
+ /**
577
+ * Handle the 'retype_prescreen' action - say, per consumer call, the reason
578
+ * the retype abstains for before any rewrite, read in the program the scan
579
+ * analysed (carrick#3132)
580
+ */
581
+ function handleRetypePrescreen(request) {
582
+ try {
583
+ const groups = byProject(request.items.map((item, index) => ({ item, index })), ({ item }) => item.file_path);
584
+ const reasons = new Array(request.items.length);
585
+ for (const [key, entries] of groups) {
586
+ projectComponents(key)
587
+ .retyper.prescreen(entries.map(({ item }) => item))
588
+ .forEach((reason, position) => {
589
+ reasons[entries[position].index] = reason;
590
+ });
591
+ }
592
+ return {
593
+ request_id: request.request_id,
594
+ status: 'success',
595
+ prescreens: request.items.map((item, index) => reasons[index] === undefined
596
+ ? { item_id: item.item_id }
597
+ : { item_id: item.item_id, reason: reasons[index] }),
598
+ };
599
+ }
600
+ catch (err) {
601
+ const error = err instanceof Error ? err.message : String(err);
602
+ logError(`Retype prescreen failed: ${error}`);
603
+ return { request_id: request.request_id, status: 'error', errors: [error] };
604
+ }
605
+ }
573
606
  /**
574
607
  * How long one verify_client_semantics or verify_library_claims request may
575
608
  * spend before the checks it has not reached come back `unchecked` with reason
@@ -703,6 +736,44 @@ function handleListProgramFiles(request) {
703
736
  return { request_id: request.request_id, status: 'error', errors: [error] };
704
737
  }
705
738
  }
739
+ /**
740
+ * Handle the 'reach_graph' action - the import graph of every program the
741
+ * process has built, the default one and each owning project's (carrick#3100).
742
+ * A process that has built none builds the default one, so a replay can ask
743
+ * after `init` alone. Paths are relative to the scan root.
744
+ */
745
+ function handleReachGraph(request) {
746
+ try {
747
+ const loader = initializedLoader();
748
+ const startTime = performance.now();
749
+ if (loader.builtProjects().length === 0)
750
+ loader.getProject();
751
+ const root = loader.getScanRoot();
752
+ const graph = serialiseGraph(mergeGraphs(loader.builtProjects().map((project) => importGraphOf(project.getProgram().compilerObject, root))));
753
+ log(`Read the import graph of ${graph.files.length} file(s) in ${Math.round(performance.now() - startTime)}ms`);
754
+ return { request_id: request.request_id, status: 'success', version: 1, graph };
755
+ }
756
+ catch (err) {
757
+ const error = err instanceof Error ? err.message : String(err);
758
+ logError(`Reading the import graph failed: ${error}`);
759
+ return { request_id: request.request_id, status: 'error', errors: [error] };
760
+ }
761
+ }
762
+ /**
763
+ * Handle the 'reach' action - the files a set of edits can reach in a graph
764
+ * `reach_graph` wrote (carrick#3100). Reads no program.
765
+ */
766
+ function handleReach(request) {
767
+ try {
768
+ const answer = reach(request.graph, request.changes);
769
+ return { request_id: request.request_id, status: 'success', ...answer };
770
+ }
771
+ catch (err) {
772
+ const error = err instanceof Error ? err.message : String(err);
773
+ logError(`Reach failed: ${error}`);
774
+ return { request_id: request.request_id, status: 'error', errors: [error] };
775
+ }
776
+ }
706
777
  /**
707
778
  * Handle the 'add_program_files' action - add the given files to the default
708
779
  * project's program in the given order, rebuilding it at most once
@@ -838,6 +909,8 @@ function handleRequest(request) {
838
909
  return handleResolveDefinitions(request);
839
910
  case 'retype_check':
840
911
  return handleRetypeCheck(request);
912
+ case 'retype_prescreen':
913
+ return handleRetypePrescreen(request);
841
914
  case 'verify_client_semantics':
842
915
  return handleVerifyClientSemantics(request);
843
916
  case 'verify_library_claims':
@@ -846,6 +919,10 @@ function handleRequest(request) {
846
919
  return handleListLibrarySurface(request);
847
920
  case 'list_program_files':
848
921
  return handleListProgramFiles(request);
922
+ case 'reach_graph':
923
+ return handleReachGraph(request);
924
+ case 'reach':
925
+ return handleReach(request);
849
926
  case 'add_program_files':
850
927
  return handleAddProgramFiles(request);
851
928
  case 'position_rows':
@@ -28,7 +28,18 @@
28
28
  * reusing earlier answers) and their modes differ, the entry cannot be placed
29
29
  * and is left unresolved rather than given another import's mode.
30
30
  */
31
- import { type ResolutionHostFactory } from 'ts-morph';
31
+ import { ts, type ResolutionHost } from 'ts-morph';
32
+ /**
33
+ * A resolution host that also hands the compiler a module resolution cache.
34
+ * ts-morph's `ResolutionHost` has no such member, and its `createHosts`
35
+ * copies only the three it declares onto the compiler host, so a host with
36
+ * its own `resolveModuleNames` left every program without a cache: the
37
+ * compiler then read the `package.json` scope above every file again on
38
+ * every rebuild (37% of a retyped call in a large program).
39
+ */
40
+ export interface CachingResolutionHost extends ResolutionHost {
41
+ getModuleResolutionCache(): ts.ModuleResolutionCache;
42
+ }
32
43
  /**
33
44
  * The editor's project-reference rule for the program's owner config
34
45
  * (`ReferenceRedirect` in `capture/reference-redirect.ts`, carrick#2418),
@@ -47,4 +58,4 @@ export interface ResolutionRedirect {
47
58
  * The resolution host factory, resolving through `redirect` when the owner
48
59
  * config references other projects.
49
60
  */
50
- export declare const moduleFormatResolutionHost: (redirect?: ResolutionRedirect) => ResolutionHostFactory;
61
+ export declare const moduleFormatResolutionHost: (redirect?: ResolutionRedirect) => (host: ts.ModuleResolutionHost, getOptions: () => ts.CompilerOptions) => CachingResolutionHost;
@@ -28,7 +28,26 @@
28
28
  * reusing earlier answers) and their modes differ, the entry cannot be placed
29
29
  * and is left unresolved rather than given another import's mode.
30
30
  */
31
+ import tsMorphCommon from '@ts-morph/common';
31
32
  import { ts } from 'ts-morph';
33
+ // The `createHosts` ts-morph calls is a property of this same CommonJS
34
+ // exports object (ts-morph reads `common.createHosts` when a project builds
35
+ // its language service), so wrapping it here reaches every project built
36
+ // after this module loads. Both copies must be one instance, or the wrap
37
+ // would silently miss: fail at load instead.
38
+ if (tsMorphCommon.ts !== ts) {
39
+ throw new Error('@ts-morph/common is not the instance ts-morph loads; pin it to the version ts-morph requires');
40
+ }
41
+ const createHosts = tsMorphCommon.createHosts;
42
+ tsMorphCommon.createHosts = (options) => {
43
+ const hosts = createHosts(options);
44
+ const cache = options.resolutionHost.getModuleResolutionCache;
45
+ // The compiler host is the one ts-morph's own program is built with. The
46
+ // language service's programs keep their own host (a named follow-up).
47
+ if (cache)
48
+ hosts.compilerHost.getModuleResolutionCache = cache;
49
+ return hosts;
50
+ };
32
51
  /** Whether the compiler decides an import's mode from the importing file's format. */
33
52
  function formatDecidesMode(options) {
34
53
  const kind = options.module;
@@ -61,16 +80,27 @@ const UNPLACED = Symbol('unplaced');
61
80
  */
62
81
  export const moduleFormatResolutionHost = (redirect) => (host, getOptions) => {
63
82
  const resolutionHost = redirect ? redirect.resolutionHost(host) : host;
83
+ // One cache per project, handed to the compiler. The compiler resolves no
84
+ // module name itself while this host does, so only its package.json entries
85
+ // fill: each file's format scope, and the packages type references reach.
86
+ // It lives as long as the project, because no package.json changes while a
87
+ // scan runs; the edits a project sees are to its source files.
88
+ const programCache = ts.createModuleResolutionCache(process.cwd(), (fileName) => fileName, getOptions());
89
+ const packageJsonCache = programCache.getPackageJsonInfoCache();
90
+ // The resolver's own module answers stay per program (each rebuild passes
91
+ // a new options object), so an answer is never carried past a rebuild; only
92
+ // the package.json reads behind them are shared.
64
93
  let cache;
65
94
  let cacheOptions;
66
95
  const cacheFor = (options) => {
67
96
  if (!cache || cacheOptions !== options) {
68
- cache = ts.createModuleResolutionCache(process.cwd(), (fileName) => fileName, options);
97
+ cache = ts.createModuleResolutionCache(process.cwd(), (fileName) => fileName, options, packageJsonCache);
69
98
  cacheOptions = options;
70
99
  }
71
100
  return cache;
72
101
  };
73
102
  return {
103
+ getModuleResolutionCache: () => programCache,
74
104
  resolveModuleNames: (moduleNames, containingFile, _reusedNames, redirectedReference, options, containingSourceFile) => {
75
105
  const compilerOptions = options ?? getOptions();
76
106
  const resolutionCache = cacheFor(compilerOptions);
@@ -187,6 +187,13 @@ export declare class ProjectLoader {
187
187
  * that, without building it (carrick#2027).
188
188
  */
189
189
  builtProject(): Project | undefined;
190
+ /**
191
+ * Every program a request has built: the default project and each owning
192
+ * project's (carrick#1604), without building any (carrick#3100).
193
+ */
194
+ builtProjects(): Project[];
195
+ /** The scanned repo's root when init named one, else the service root. */
196
+ getScanRoot(): string;
190
197
  /**
191
198
  * The registry package a resolved file belongs to, when the module graph
192
199
  * names one (carrick#1260). `undefined` for a project that did not resolve
@@ -509,6 +509,17 @@ export class ProjectLoader {
509
509
  builtProject() {
510
510
  return this.project ?? undefined;
511
511
  }
512
+ /**
513
+ * Every program a request has built: the default project and each owning
514
+ * project's (carrick#1604), without building any (carrick#3100).
515
+ */
516
+ builtProjects() {
517
+ return [...(this.project ? [this.project] : []), ...this.ownerProjects.values()];
518
+ }
519
+ /** The scanned repo's root when init named one, else the service root. */
520
+ getScanRoot() {
521
+ return this.scanRoot ?? this.repoRoot;
522
+ }
512
523
  /**
513
524
  * The registry package a resolved file belongs to, when the module graph
514
525
  * names one (carrick#1260). `undefined` for a project that did not resolve
@@ -27,7 +27,7 @@
27
27
  import { ts } from 'ts-morph';
28
28
  import type { Project } from 'ts-morph';
29
29
  import type { TypeInferrer } from './type-inferrer.js';
30
- import type { RetypeItem, RetypeOutcome } from './types.js';
30
+ import type { RetypeItem, RetypeLocatorItem, RetypeOutcome } from './types.js';
31
31
  /**
32
32
  * The check phase's structural any/unknown walk (`findDisqualifyingTopTypes`
33
33
  * in the capture bundle): member paths below `root` that hold a top type.
@@ -59,14 +59,30 @@ export declare class Retyper {
59
59
  */
60
60
  run(items: RetypeItem[], budgetMs: number, onJudged?: () => void): RetypeOutcome[];
61
61
  private runOne;
62
+ /**
63
+ * Per item, the reason `run` abstains for before any rewrite, which no
64
+ * producer type changes, or `undefined` when only the rewrite can decide
65
+ * the call (carrick#3132). The scan asks this in the consumer's own
66
+ * analysis, so a consumer whose calls all abstain here builds no retype
67
+ * program. A call that throws here is left to the retype, which reports
68
+ * the failure itself.
69
+ */
70
+ prescreen(items: RetypeLocatorItem[]): Array<string | undefined>;
71
+ /**
72
+ * The call and how to state a type at it, or why the retype abstains
73
+ * before any rewrite. Reads only the consumer's own code: the producer's
74
+ * type is stated by the returned plan.
75
+ */
76
+ private beforeRewrite;
62
77
  /**
63
78
  * The rewrite that states the producer's UNWIDENED return (carrick#1516),
64
79
  * when the item carries one that can be stated at this call.
65
80
  */
66
81
  private unwidenedPlan;
67
82
  /**
68
- * How to state the producer's type at this call, or why it cannot be done.
69
- * Returns a builder so the wire and the declared form share one decision.
83
+ * How to state a producer's type at this call, or why it cannot be done
84
+ * whatever that type is. The builder it returns takes the type, and then
85
+ * builds the wire and the declared form from one decision.
70
86
  */
71
87
  private plan;
72
88
  /**