gitnexus 1.6.5 → 1.6.6-rc.2
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.
- package/dist/_shared/index.d.ts +2 -2
- package/dist/_shared/index.d.ts.map +1 -1
- package/dist/_shared/index.js.map +1 -1
- package/dist/_shared/scope-resolution/registries/context.d.ts +27 -0
- package/dist/_shared/scope-resolution/registries/context.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/registries/context.js.map +1 -1
- package/dist/_shared/scope-resolution/symbol-definition.d.ts +20 -0
- package/dist/_shared/scope-resolution/symbol-definition.d.ts.map +1 -1
- package/dist/core/ingestion/language-provider.d.ts +29 -0
- package/dist/core/ingestion/languages/c-cpp.js +46 -0
- package/dist/core/ingestion/languages/cpp/arity-metadata.d.ts +17 -0
- package/dist/core/ingestion/languages/cpp/arity-metadata.js +51 -2
- package/dist/core/ingestion/languages/cpp/arity.d.ts +4 -1
- package/dist/core/ingestion/languages/cpp/arity.js +4 -1
- package/dist/core/ingestion/languages/cpp/captures.js +73 -0
- package/dist/core/ingestion/languages/cpp/constraint-extractor.d.ts +73 -0
- package/dist/core/ingestion/languages/cpp/constraint-extractor.js +308 -0
- package/dist/core/ingestion/languages/cpp/constraint-filter.d.ts +31 -0
- package/dist/core/ingestion/languages/cpp/constraint-filter.js +135 -0
- package/dist/core/ingestion/languages/cpp/scope-resolver.js +6 -0
- package/dist/core/ingestion/languages/cpp/type-classifier.d.ts +26 -0
- package/dist/core/ingestion/languages/cpp/type-classifier.js +49 -0
- package/dist/core/ingestion/model/symbol-table.d.ts +2 -1
- package/dist/core/ingestion/model/symbol-table.js +3 -0
- package/dist/core/ingestion/parsing-processor.js +35 -2
- package/dist/core/ingestion/scope-extractor.js +63 -0
- package/dist/core/ingestion/scope-resolution/contract/scope-resolver.d.ts +21 -1
- package/dist/core/ingestion/scope-resolution/graph-bridge/ids.d.ts +1 -0
- package/dist/core/ingestion/scope-resolution/graph-bridge/ids.js +14 -0
- package/dist/core/ingestion/scope-resolution/graph-bridge/node-lookup.js +12 -0
- package/dist/core/ingestion/scope-resolution/passes/free-call-fallback.d.ts +11 -1
- package/dist/core/ingestion/scope-resolution/passes/free-call-fallback.js +50 -21
- package/dist/core/ingestion/scope-resolution/passes/overload-narrowing.d.ts +30 -7
- package/dist/core/ingestion/scope-resolution/passes/overload-narrowing.js +49 -18
- package/dist/core/ingestion/scope-resolution/passes/receiver-bound-calls.d.ts +1 -1
- package/dist/core/ingestion/scope-resolution/passes/receiver-bound-calls.js +10 -4
- package/dist/core/ingestion/scope-resolution/pipeline/run.js +1 -0
- package/dist/core/ingestion/utils/template-arguments.d.ts +19 -0
- package/dist/core/ingestion/utils/template-arguments.js +30 -0
- package/dist/core/ingestion/workers/parse-worker.d.ts +2 -1
- package/dist/core/ingestion/workers/parse-worker.js +1 -0
- package/package.json +1 -1
package/dist/_shared/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { SupportedLanguages } from './languages.js';
|
|
|
5
5
|
export { getLanguageFromFilename, getSyntaxLanguageFromFilename } from './language-detection.js';
|
|
6
6
|
export type { MroStrategy } from './mro-strategy.js';
|
|
7
7
|
export type { PipelinePhase, PipelineProgress } from './pipeline.js';
|
|
8
|
-
export type { SymbolDefinition } from './scope-resolution/symbol-definition.js';
|
|
8
|
+
export type { ParameterTypeClass, SymbolDefinition } from './scope-resolution/symbol-definition.js';
|
|
9
9
|
export type { ScopeId, DefId, ScopeKind, Range, Capture, CaptureMatch, BindingRef, ImportEdge, TypeRef, Scope, ResolutionEvidence, Resolution, Reference, ReferenceIndex, LookupParams, RegistryContributor, ParsedImport, ParsedTypeBinding, WorkspaceIndex, Callsite, ScopeLookup, } from './scope-resolution/types.js';
|
|
10
10
|
export { EvidenceWeights, typeBindingWeightAtDepth } from './scope-resolution/evidence-weights.js';
|
|
11
11
|
export { ORIGIN_PRIORITY } from './scope-resolution/origin-priority.js';
|
|
@@ -41,7 +41,7 @@ export type { RawSignals } from './scope-resolution/registries/evidence.js';
|
|
|
41
41
|
export { compareByConfidenceWithTiebreaks, CONFIDENCE_EPSILON, } from './scope-resolution/registries/tie-breaks.js';
|
|
42
42
|
export type { TieBreakKey } from './scope-resolution/registries/tie-breaks.js';
|
|
43
43
|
export { CLASS_KINDS, METHOD_KINDS, FIELD_KINDS } from './scope-resolution/registries/context.js';
|
|
44
|
-
export type { RegistryContext, RegistryProviders, OwnerScopedContributor, ArityVerdict, } from './scope-resolution/registries/context.js';
|
|
44
|
+
export type { RegistryContext, RegistryProviders, OwnerScopedContributor, ArityVerdict, ConstraintContext, } from './scope-resolution/registries/context.js';
|
|
45
45
|
export { makeScopeId, clearScopeIdInternPool } from './scope-resolution/scope-id.js';
|
|
46
46
|
export type { ScopeIdInput } from './scope-resolution/scope-id.js';
|
|
47
47
|
export { buildScopeTree, canParentScope, ScopeTreeInvariantError, } from './scope-resolution/scope-tree.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,WAAW,EACX,cAAc,EACd,SAAS,EACT,oBAAoB,GACrB,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAGzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AACjG,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAIrE,YAAY,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":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CAAC;AAEjG,OAAO,EACL,cAAc,EACd,4BAA4B,EAC5B,kBAAkB,EAClB,eAAe,GAChB,MAAM,mCAAmC,CAAC;AAG3C,mDAAmD;AACnD,OAAO,EACL,+BAA+B,EAC/B,6BAA6B,EAC7B,4BAA4B,EAC5B,sBAAsB,EACtB,gBAAgB,EAChB,wBAAwB,EACxB,cAAc,GACf,MAAM,sCAAsC,CAAC;AAG9C,gEAAgE;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAMpE,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC"}
|
|
@@ -26,8 +26,35 @@ export interface RegistryProviders {
|
|
|
26
26
|
* when absent, every candidate receives `'unknown'` (neutral signal).
|
|
27
27
|
*/
|
|
28
28
|
arityCompatibility?(callsite: Callsite, def: SymbolDefinition): ArityVerdict;
|
|
29
|
+
/**
|
|
30
|
+
* Language-specific constraint compatibility between a callsite and a
|
|
31
|
+
* candidate `def`. Mirrors `arityCompatibility` and shares its three-valued
|
|
32
|
+
* verdict shape; the third value `'unknown'` MUST keep the candidate
|
|
33
|
+
* (monotonicity: adding a predicate can only narrow correctly, never
|
|
34
|
+
* produce a wrong edge). Consulted by `narrowOverloadCandidates` after
|
|
35
|
+
* arity + type filters when a candidate carries `templateConstraints`.
|
|
36
|
+
*
|
|
37
|
+
* Optional; when absent the constraint filter is a pass-through. Languages
|
|
38
|
+
* with no constrained-overload semantics leave this undefined.
|
|
39
|
+
*/
|
|
40
|
+
constraintCompatibility?(callsite: Callsite, def: SymbolDefinition, ctx: ConstraintContext): ArityVerdict;
|
|
29
41
|
}
|
|
30
42
|
export type ArityVerdict = 'compatible' | 'unknown' | 'incompatible';
|
|
43
|
+
/**
|
|
44
|
+
* Context threaded into `constraintCompatibility`. Kept minimal in the
|
|
45
|
+
* Tier-A scope (only `argumentTypes`, riding here until a separate
|
|
46
|
+
* `Callsite`-widening refactor moves them onto the call site directly).
|
|
47
|
+
* Future Tier-B graph-aware predicates (`is_base_of_v`, etc.) will widen
|
|
48
|
+
* this interface with `lookupTypeByName` and similar helpers.
|
|
49
|
+
*/
|
|
50
|
+
export interface ConstraintContext {
|
|
51
|
+
/**
|
|
52
|
+
* Per-slot argument types at the call site, normalized per the language
|
|
53
|
+
* adapter. Empty string means unknown. Same convention as
|
|
54
|
+
* `narrowOverloadCandidates`' `argTypes` parameter.
|
|
55
|
+
*/
|
|
56
|
+
readonly argumentTypes?: readonly string[];
|
|
57
|
+
}
|
|
31
58
|
/**
|
|
32
59
|
* Per-owner membership view plugged into `LookupParams.ownerScopedContributor`.
|
|
33
60
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/scope-resolution/registries/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAIvE,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,kBAAkB,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,gBAAgB,GAAG,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/scope-resolution/registries/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GA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C,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,cAAc,EAAE,kBAAkB,CAAC;IAC5C,QAAQ,CAAC,YAAY,EAAE,gBAAgB,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,mBAAmB,CAAC;IAC9C,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;CACvC;AAOD,eAAO,MAAM,WAAW,EAAE,SAAS,SAAS,EAc1C,CAAC;AAEH,eAAO,MAAM,YAAY,EAAE,SAAS,SAAS,EAI3C,CAAC;AAEH,eAAO,MAAM,WAAW,EAAE,SAAS,SAAS,EAK1C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/scope-resolution/registries/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/scope-resolution/registries/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAkGH,8EAA8E;AAC9E,EAAE;AACF,0EAA0E;AAC1E,6DAA6D;AAE7D,MAAM,CAAC,MAAM,WAAW,GAAyB,MAAM,CAAC,MAAM,CAAC;IAC7D,OAAO;IACP,WAAW;IACX,MAAM;IACN,QAAQ;IACR,OAAO;IACP,OAAO;IACP,WAAW;IACX,SAAS;IACT,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,UAAU;IACV,WAAW;CACZ,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAyB,MAAM,CAAC,MAAM,CAAC;IAC9D,QAAQ;IACR,UAAU;IACV,aAAa;CACd,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAyB,MAAM,CAAC,MAAM,CAAC;IAC7D,UAAU;IACV,UAAU;IACV,OAAO;IACP,QAAQ;CACT,CAAC,CAAC"}
|
|
@@ -9,6 +9,16 @@
|
|
|
9
9
|
* Shape is unchanged from the prior local definition.
|
|
10
10
|
*/
|
|
11
11
|
import type { NodeLabel } from '../graph/types.js';
|
|
12
|
+
export interface ParameterTypeClass {
|
|
13
|
+
/** Normalized base type, matching the coarse `parameterTypes` vocabulary when known. */
|
|
14
|
+
base: string;
|
|
15
|
+
/** Top-level cv signal preserved from the original C++ parameter spelling. */
|
|
16
|
+
cv: 'none' | 'const' | 'volatile' | 'const volatile' | 'unknown';
|
|
17
|
+
/** Coarse value/reference/pointer shape. */
|
|
18
|
+
indirection: 'value' | 'lvalue-ref' | 'rvalue-ref' | 'pointer' | 'unknown';
|
|
19
|
+
/** Number of pointer markers when indirection is `pointer`; otherwise 0. */
|
|
20
|
+
pointerDepth: number;
|
|
21
|
+
}
|
|
12
22
|
export interface SymbolDefinition {
|
|
13
23
|
nodeId: string;
|
|
14
24
|
filePath: string;
|
|
@@ -24,12 +34,22 @@ export interface SymbolDefinition {
|
|
|
24
34
|
/** Per-parameter type names for overload disambiguation (e.g. ['int', 'String']).
|
|
25
35
|
* Populated when parameter types are resolvable from AST (any typed language). */
|
|
26
36
|
parameterTypes?: string[];
|
|
37
|
+
/** Additive per-parameter type shape sidecar for languages that need cv/ref/pointer distinctions.
|
|
38
|
+
* Does not participate in graph node identity unless a resolver explicitly opts in. */
|
|
39
|
+
parameterTypeClasses?: ParameterTypeClass[];
|
|
27
40
|
/** Raw return type text extracted from AST (e.g. 'User', 'Promise<User>') */
|
|
28
41
|
returnType?: string;
|
|
29
42
|
/** Declared type for non-callable symbols — fields/properties (e.g. 'Address', 'List<User>') */
|
|
30
43
|
declaredType?: string;
|
|
31
44
|
/** Generic/template specialization arguments for class-like symbols (e.g. ['User'], ['T*']). */
|
|
32
45
|
templateArguments?: string[];
|
|
46
|
+
/** Per-language constraint payload for template / generic overloads
|
|
47
|
+
* (e.g. C++ `enable_if_t<P, T>` predicate trees, C++20 `requires` clauses).
|
|
48
|
+
* Opaque to shared code — the producing language adapter owns the shape
|
|
49
|
+
* and is the only consumer. Read via the optional
|
|
50
|
+
* `ScopeResolver.constraintCompatibility` hook during overload narrowing.
|
|
51
|
+
* Absent for symbols that have no constraints (the common case). */
|
|
52
|
+
templateConstraints?: unknown;
|
|
33
53
|
/** Links Method/Constructor/Property to owning Class/Struct/Trait nodeId */
|
|
34
54
|
ownerId?: string;
|
|
35
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbol-definition.d.ts","sourceRoot":"","sources":["../../src/scope-resolution/symbol-definition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,SAAS,CAAC;IAChB;;+FAE2F;IAC3F,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;iHAC6G;IAC7G,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;uFACmF;IACnF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,6EAA6E;IAC7E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gGAAgG;IAChG,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gGAAgG;IAChG,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
1
|
+
{"version":3,"file":"symbol-definition.d.ts","sourceRoot":"","sources":["../../src/scope-resolution/symbol-definition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,WAAW,kBAAkB;IACjC,wFAAwF;IACxF,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,gBAAgB,GAAG,SAAS,CAAC;IACjE,4CAA4C;IAC5C,WAAW,EAAE,OAAO,GAAG,YAAY,GAAG,YAAY,GAAG,SAAS,GAAG,SAAS,CAAC;IAC3E,4EAA4E;IAC5E,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,SAAS,CAAC;IAChB;;+FAE2F;IAC3F,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;iHAC6G;IAC7G,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;uFACmF;IACnF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B;4FACwF;IACxF,oBAAoB,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC5C,6EAA6E;IAC7E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gGAAgG;IAChG,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gGAAgG;IAChG,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B;;;;;yEAKqE;IACrE,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -155,6 +155,35 @@ interface LanguageProviderConfig {
|
|
|
155
155
|
funcName: string;
|
|
156
156
|
label: NodeLabel;
|
|
157
157
|
} | null;
|
|
158
|
+
/**
|
|
159
|
+
* Extract a per-language template-constraint payload for a templated
|
|
160
|
+
* function / method definition. Used by `parsing-processor` to
|
|
161
|
+
* disambiguate same-name same-arity overloads whose distinguishing
|
|
162
|
+
* signal is their template constraints rather than their parameter
|
|
163
|
+
* types — the canonical C++ SFINAE case (issue #1579):
|
|
164
|
+
*
|
|
165
|
+
* template<class T, std::enable_if_t<is_integral_v<T>, int> = 0>
|
|
166
|
+
* void process(T); // overload A
|
|
167
|
+
*
|
|
168
|
+
* template<class T, std::enable_if_t<is_floating_point_v<T>, int> = 0>
|
|
169
|
+
* void process(T); // overload B
|
|
170
|
+
*
|
|
171
|
+
* Both overloads' `parameterTypes` collapse to `['T']`, so without a
|
|
172
|
+
* constraint fingerprint in the graph node ID they merge into one
|
|
173
|
+
* Function node and the resolver only ever sees one candidate to
|
|
174
|
+
* narrow. The hook's return value is stamped onto the node's ID via
|
|
175
|
+
* `templateConstraintsIdTag()` AND stored on the node's
|
|
176
|
+
* `templateConstraints` property so `resolveDefGraphId` can look up
|
|
177
|
+
* the right overload by re-hashing the def's constraints at resolve
|
|
178
|
+
* time.
|
|
179
|
+
*
|
|
180
|
+
* Returns the opaque payload (any JSON-serializable shape — the
|
|
181
|
+
* producing adapter owns it; shared code MUST NOT inspect) or
|
|
182
|
+
* `undefined` when no constraints exist / the node isn't a templated
|
|
183
|
+
* function. Languages without SFINAE / concept semantics leave this
|
|
184
|
+
* undefined and the disambiguation is a pass-through.
|
|
185
|
+
*/
|
|
186
|
+
readonly extractTemplateConstraints?: (definitionNode: SyntaxNode) => unknown;
|
|
158
187
|
/** Override the default node label for definition.function captures.
|
|
159
188
|
* Return null to skip (C/C++ duplicate), a different label to reclassify
|
|
160
189
|
* (e.g., 'Method' for Kotlin), or defaultLabel to keep as-is.
|
|
@@ -39,6 +39,7 @@ import { createHeritageExtractor } from '../heritage-extractors/generic.js';
|
|
|
39
39
|
import { stripUeMacros } from '../cpp-ue-preprocessor.js';
|
|
40
40
|
import { emitCScopeCaptures, interpretCImport, interpretCTypeBinding, cArityCompatibility, cBindingScopeFor, cImportOwningScope, cReceiverBinding, } from './c/index.js';
|
|
41
41
|
import { emitCppScopeCaptures, interpretCppImport, interpretCppTypeBinding, cppArityCompatibility, cppBindingScopeFor, cppImportOwningScope, cppReceiverBinding, } from './cpp/index.js';
|
|
42
|
+
import { extractCppTemplateConstraints } from './cpp/constraint-extractor.js';
|
|
42
43
|
const C_BUILT_INS = new Set([
|
|
43
44
|
'printf',
|
|
44
45
|
'fprintf',
|
|
@@ -417,6 +418,7 @@ export const cppProvider = defineLanguage({
|
|
|
417
418
|
heritageExtractor: createHeritageExtractor(SupportedLanguages.CPlusPlus),
|
|
418
419
|
labelOverride: cppLabelOverride,
|
|
419
420
|
builtInNames: C_BUILT_INS,
|
|
421
|
+
extractTemplateConstraints: extractCppTemplateConstraintsForProvider,
|
|
420
422
|
// ── RFC #909 Ring 3: scope-based resolution hooks (RFC §5) ──────────
|
|
421
423
|
emitScopeCaptures: emitCppScopeCaptures,
|
|
422
424
|
interpretImport: interpretCppImport,
|
|
@@ -427,3 +429,47 @@ export const cppProvider = defineLanguage({
|
|
|
427
429
|
arityCompatibility: cppArityCompatibility,
|
|
428
430
|
// mergeBindings + resolveImportTarget live on ScopeResolver (see cpp/scope-resolver.ts).
|
|
429
431
|
});
|
|
432
|
+
/**
|
|
433
|
+
* LanguageProvider hook: walk from a function definition node up to its
|
|
434
|
+
* enclosing `template_declaration` and extract the SFINAE / `requires`-
|
|
435
|
+
* clause constraint payload. Used by `parsing-processor` to fingerprint
|
|
436
|
+
* the graph node ID so two SFINAE overloads with identical
|
|
437
|
+
* `parameterTypes` get distinct nodes (issue #1579).
|
|
438
|
+
*
|
|
439
|
+
* Returns `undefined` for non-templated functions and for templated
|
|
440
|
+
* functions whose constraints the extractor can't model — both cases
|
|
441
|
+
* result in no constraint suffix on the node ID.
|
|
442
|
+
*/
|
|
443
|
+
function extractCppTemplateConstraintsForProvider(definitionNode) {
|
|
444
|
+
// Walk up to the enclosing template_declaration. Bound the walk so we
|
|
445
|
+
// can't accidentally land on a far-ancestor template_declaration that
|
|
446
|
+
// wraps an unrelated function.
|
|
447
|
+
let cur = definitionNode.parent;
|
|
448
|
+
let hops = 8;
|
|
449
|
+
let templateDecl = null;
|
|
450
|
+
while (cur !== null && hops-- > 0) {
|
|
451
|
+
if (cur.type === 'template_declaration') {
|
|
452
|
+
templateDecl = cur;
|
|
453
|
+
break;
|
|
454
|
+
}
|
|
455
|
+
if (cur.type === 'translation_unit')
|
|
456
|
+
break;
|
|
457
|
+
cur = cur.parent;
|
|
458
|
+
}
|
|
459
|
+
if (templateDecl === null)
|
|
460
|
+
return undefined;
|
|
461
|
+
// Find the function_declarator inside the function definition so the
|
|
462
|
+
// extractor can map template params to function-argument indices.
|
|
463
|
+
let declarator = definitionNode.childForFieldName('declarator');
|
|
464
|
+
let walk = 8;
|
|
465
|
+
while (declarator !== null && walk-- > 0) {
|
|
466
|
+
if (declarator.type === 'function_declarator')
|
|
467
|
+
break;
|
|
468
|
+
if (declarator.type === 'pointer_declarator' || declarator.type === 'reference_declarator') {
|
|
469
|
+
declarator = declarator.childForFieldName('declarator');
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
472
|
+
break;
|
|
473
|
+
}
|
|
474
|
+
return extractCppTemplateConstraints(templateDecl, declarator);
|
|
475
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { SyntaxNode } from '../../utils/ast-helpers.js';
|
|
2
|
+
import type { ParameterTypeClass } from '../../../../_shared/index.js';
|
|
2
3
|
export interface CppArityInfo {
|
|
3
4
|
parameterCount?: number;
|
|
4
5
|
requiredParameterCount?: number;
|
|
5
6
|
parameterTypes?: string[];
|
|
7
|
+
parameterTypeClasses?: ParameterTypeClass[];
|
|
6
8
|
}
|
|
7
9
|
/**
|
|
8
10
|
* Compute declaration arity from a C++ function definition or declaration node.
|
|
@@ -16,3 +18,18 @@ export declare function computeCppDeclarationArity(node: SyntaxNode): CppArityIn
|
|
|
16
18
|
* Compute call-site arity from a call_expression node.
|
|
17
19
|
*/
|
|
18
20
|
export declare function computeCppCallArity(node: SyntaxNode): number;
|
|
21
|
+
/**
|
|
22
|
+
* Normalize a C++ parameter type for overload disambiguation.
|
|
23
|
+
* Maps common qualified/aliased types to their canonical short forms
|
|
24
|
+
* so that `narrowOverloadCandidates` can match against literal-inferred
|
|
25
|
+
* argument types (e.g. `inferCppLiteralType` returns `'string'` for
|
|
26
|
+
* string literals, not `'std::string'`).
|
|
27
|
+
*
|
|
28
|
+
* This intentionally remains coarse and graph-ID-stable: cv-qualifiers,
|
|
29
|
+
* reference markers, and pointer markers are stripped here. C++ callers
|
|
30
|
+
* that need those distinctions should read `parameterTypeClasses`, which
|
|
31
|
+
* is an additive sidecar and does not participate in overload node ID
|
|
32
|
+
* hashing.
|
|
33
|
+
*/
|
|
34
|
+
export declare function normalizeCppParamType(raw: string): string;
|
|
35
|
+
export declare function classifyCppParameterType(rawType: string, declaratorText?: string, fullParameterText?: string): ParameterTypeClass;
|
|
@@ -55,27 +55,34 @@ export function computeCppDeclarationArity(node) {
|
|
|
55
55
|
p.type === 'variadic_parameter_declaration').length;
|
|
56
56
|
const totalNonVariadic = requiredCount + optionalCount;
|
|
57
57
|
const types = [];
|
|
58
|
+
const typeClasses = [];
|
|
58
59
|
for (const p of params) {
|
|
59
60
|
if (p.type === 'variadic_parameter') {
|
|
60
61
|
types.push('...');
|
|
62
|
+
typeClasses.push(unknownTypeClass('...'));
|
|
61
63
|
}
|
|
62
64
|
else if (p.type === 'variadic_parameter_declaration') {
|
|
63
65
|
// Parameter pack: treated as variadic
|
|
64
66
|
types.push('...');
|
|
67
|
+
typeClasses.push(unknownTypeClass('...'));
|
|
65
68
|
}
|
|
66
69
|
else {
|
|
67
70
|
const typeNode = p.childForFieldName('type');
|
|
68
|
-
|
|
71
|
+
const rawType = typeNode?.text ?? 'unknown';
|
|
72
|
+
types.push(normalizeCppParamType(rawType));
|
|
73
|
+
typeClasses.push(classifyCppParameterType(rawType, p.childForFieldName('declarator')?.text, p.text));
|
|
69
74
|
}
|
|
70
75
|
}
|
|
71
76
|
// Append '...' for C-style variadic if not already in types
|
|
72
77
|
if (hasEllipsis && !types.includes('...')) {
|
|
73
78
|
types.push('...');
|
|
79
|
+
typeClasses.push(unknownTypeClass('...'));
|
|
74
80
|
}
|
|
75
81
|
return {
|
|
76
82
|
parameterCount: isVariadic ? undefined : totalNonVariadic,
|
|
77
83
|
requiredParameterCount: requiredCount,
|
|
78
84
|
parameterTypes: types,
|
|
85
|
+
parameterTypeClasses: typeClasses,
|
|
79
86
|
};
|
|
80
87
|
}
|
|
81
88
|
/**
|
|
@@ -102,8 +109,14 @@ export function computeCppCallArity(node) {
|
|
|
102
109
|
* so that `narrowOverloadCandidates` can match against literal-inferred
|
|
103
110
|
* argument types (e.g. `inferCppLiteralType` returns `'string'` for
|
|
104
111
|
* string literals, not `'std::string'`).
|
|
112
|
+
*
|
|
113
|
+
* This intentionally remains coarse and graph-ID-stable: cv-qualifiers,
|
|
114
|
+
* reference markers, and pointer markers are stripped here. C++ callers
|
|
115
|
+
* that need those distinctions should read `parameterTypeClasses`, which
|
|
116
|
+
* is an additive sidecar and does not participate in overload node ID
|
|
117
|
+
* hashing.
|
|
105
118
|
*/
|
|
106
|
-
function normalizeCppParamType(raw) {
|
|
119
|
+
export function normalizeCppParamType(raw) {
|
|
107
120
|
let t = raw.trim();
|
|
108
121
|
// Strip const, volatile, etc.
|
|
109
122
|
t = t.replace(/\b(const|volatile|restrict|mutable|constexpr)\b/g, '').trim();
|
|
@@ -140,6 +153,42 @@ function normalizeCppParamType(raw) {
|
|
|
140
153
|
};
|
|
141
154
|
return STD_MAP[t] ?? t;
|
|
142
155
|
}
|
|
156
|
+
export function classifyCppParameterType(rawType, declaratorText, fullParameterText) {
|
|
157
|
+
const source = fullParameterText ?? `${rawType} ${declaratorText ?? ''}`.trim();
|
|
158
|
+
if (rawType === 'unknown')
|
|
159
|
+
return unknownTypeClass('unknown');
|
|
160
|
+
const hasConst = /\bconst\b/.test(source);
|
|
161
|
+
const hasVolatile = /\bvolatile\b/.test(source);
|
|
162
|
+
const cv = hasConst && hasVolatile
|
|
163
|
+
? 'const volatile'
|
|
164
|
+
: hasConst
|
|
165
|
+
? 'const'
|
|
166
|
+
: hasVolatile
|
|
167
|
+
? 'volatile'
|
|
168
|
+
: 'none';
|
|
169
|
+
const pointerDepth = (source.match(/\*/g) ?? []).length;
|
|
170
|
+
const indirection = pointerDepth > 0
|
|
171
|
+
? 'pointer'
|
|
172
|
+
: /&&/.test(source)
|
|
173
|
+
? 'rvalue-ref'
|
|
174
|
+
: /&/.test(source)
|
|
175
|
+
? 'lvalue-ref'
|
|
176
|
+
: 'value';
|
|
177
|
+
return {
|
|
178
|
+
base: normalizeCppParamType(rawType),
|
|
179
|
+
cv,
|
|
180
|
+
indirection,
|
|
181
|
+
pointerDepth,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function unknownTypeClass(base) {
|
|
185
|
+
return {
|
|
186
|
+
base,
|
|
187
|
+
cv: 'unknown',
|
|
188
|
+
indirection: 'unknown',
|
|
189
|
+
pointerDepth: 0,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
143
192
|
function findFuncDeclarator(node) {
|
|
144
193
|
let decl = node.childForFieldName('declarator');
|
|
145
194
|
if (decl === null) {
|
|
@@ -7,7 +7,10 @@ import type { Callsite, SymbolDefinition } from '../../../../_shared/index.js';
|
|
|
7
7
|
* - Default parameters (requiredParameterCount < parameterCount)
|
|
8
8
|
* - Variadic functions (C-style `...`)
|
|
9
9
|
* - Parameter packs (V1: treated as variadic)
|
|
10
|
-
* - Templates
|
|
10
|
+
* - Templates: arity check on non-template params; SFINAE / `requires`
|
|
11
|
+
* constraints are filtered separately via `constraintCompatibility`
|
|
12
|
+
* (see `constraint-filter.ts` and issue #1579). Type-argument generic
|
|
13
|
+
* substitution (`List<T>` ≡ `List<U>`) remains out of V1 scope.
|
|
11
14
|
*
|
|
12
15
|
* Verdict:
|
|
13
16
|
* - 'compatible': callsite.arity fits within [required, total] range
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
* - Default parameters (requiredParameterCount < parameterCount)
|
|
7
7
|
* - Variadic functions (C-style `...`)
|
|
8
8
|
* - Parameter packs (V1: treated as variadic)
|
|
9
|
-
* - Templates
|
|
9
|
+
* - Templates: arity check on non-template params; SFINAE / `requires`
|
|
10
|
+
* constraints are filtered separately via `constraintCompatibility`
|
|
11
|
+
* (see `constraint-filter.ts` and issue #1579). Type-argument generic
|
|
12
|
+
* substitution (`List<T>` ≡ `List<U>`) remains out of V1 scope.
|
|
10
13
|
*
|
|
11
14
|
* Verdict:
|
|
12
15
|
* - 'compatible': callsite.arity fits within [required, total] range
|
|
@@ -8,6 +8,7 @@ import { markCppAnonymousNamespaceRange, markFileLocal } from './file-local-link
|
|
|
8
8
|
import { markCppDependentBase } from './two-phase-lookup.js';
|
|
9
9
|
import { markCppAdlSiteArgs, markCppAdlSiteNoAdl } from './adl.js';
|
|
10
10
|
import { markCppInlineNamespaceRange } from './inline-namespaces.js';
|
|
11
|
+
import { extractCppTemplateConstraints } from './constraint-extractor.js';
|
|
11
12
|
export function emitCppScopeCaptures(sourceText, filePath, cachedTree) {
|
|
12
13
|
let tree = cachedTree;
|
|
13
14
|
if (tree === undefined) {
|
|
@@ -85,6 +86,9 @@ export function emitCppScopeCaptures(sourceText, filePath, cachedTree) {
|
|
|
85
86
|
if (arity.parameterTypes !== undefined) {
|
|
86
87
|
grouped['@declaration.parameter-types'] = syntheticCapture('@declaration.parameter-types', fnNode, JSON.stringify(arity.parameterTypes));
|
|
87
88
|
}
|
|
89
|
+
if (arity.parameterTypeClasses !== undefined) {
|
|
90
|
+
grouped['@declaration.parameter-type-classes'] = syntheticCapture('@declaration.parameter-type-classes', fnNode, JSON.stringify(arity.parameterTypeClasses));
|
|
91
|
+
}
|
|
88
92
|
// Detect static storage class (file-local linkage)
|
|
89
93
|
if (hasStaticStorageClass(fnNode)) {
|
|
90
94
|
const nameText = grouped['@declaration.name']?.text;
|
|
@@ -99,6 +103,19 @@ export function emitCppScopeCaptures(sourceText, filePath, cachedTree) {
|
|
|
99
103
|
markFileLocal(filePath, nameText);
|
|
100
104
|
}
|
|
101
105
|
}
|
|
106
|
+
// SFINAE / `requires`-clause aware constraints for overload
|
|
107
|
+
// narrowing (issue #1579). Walk from the enclosing
|
|
108
|
+
// `template_declaration` — not the inner `function_definition` —
|
|
109
|
+
// so inline method templates (`template<...> class C { template<...> void f(); }`)
|
|
110
|
+
// pick up the correct outer constraint scope.
|
|
111
|
+
const templateDecl = findEnclosingTemplateDeclaration(fnNode);
|
|
112
|
+
if (templateDecl !== null) {
|
|
113
|
+
const funcDeclarator = findFunctionDeclarator(fnNode);
|
|
114
|
+
const constraints = extractCppTemplateConstraints(templateDecl, funcDeclarator);
|
|
115
|
+
if (constraints !== undefined) {
|
|
116
|
+
grouped['@declaration.template-constraints'] = syntheticCapture('@declaration.template-constraints', fnNode, JSON.stringify(constraints));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
102
119
|
}
|
|
103
120
|
}
|
|
104
121
|
// ── Detect static variables (file-local linkage) ────────────────
|
|
@@ -484,6 +501,53 @@ function extractBaseLookupName(baseNode) {
|
|
|
484
501
|
}
|
|
485
502
|
return '';
|
|
486
503
|
}
|
|
504
|
+
/**
|
|
505
|
+
* Walk parent chain from a function_definition / declaration / field_declaration
|
|
506
|
+
* to find the enclosing `template_declaration`. Returns null when the function
|
|
507
|
+
* isn't templated. The walk only ascends through wrapper nodes the C++
|
|
508
|
+
* grammar inserts between `template_declaration` and the function — direct
|
|
509
|
+
* parent in the common case, two hops for member templates whose outer
|
|
510
|
+
* class is also templated (we return the INNERMOST template_declaration,
|
|
511
|
+
* which carries this function's own template parameters).
|
|
512
|
+
*/
|
|
513
|
+
function findEnclosingTemplateDeclaration(fnNode) {
|
|
514
|
+
let cur = fnNode.parent;
|
|
515
|
+
// Cap the walk — `template_declaration` is typically the immediate parent
|
|
516
|
+
// or one wrapper away. Anything deeper is an inline-method-in-template
|
|
517
|
+
// shape and we still want the innermost templates_declaration whose body
|
|
518
|
+
// wraps `fnNode`.
|
|
519
|
+
let hops = 8;
|
|
520
|
+
while (cur !== null && hops-- > 0) {
|
|
521
|
+
if (cur.type === 'template_declaration')
|
|
522
|
+
return cur;
|
|
523
|
+
// Don't ascend past structural boundaries that should reset template scope.
|
|
524
|
+
if (cur.type === 'translation_unit')
|
|
525
|
+
return null;
|
|
526
|
+
cur = cur.parent;
|
|
527
|
+
}
|
|
528
|
+
return null;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Locate the `function_declarator` AST node within a function definition
|
|
532
|
+
* or declaration. Unwraps pointer/reference declarator wrappers. Returns
|
|
533
|
+
* null when no function_declarator is found (e.g. variable declaration
|
|
534
|
+
* mis-classified upstream).
|
|
535
|
+
*/
|
|
536
|
+
function findFunctionDeclarator(fnNode) {
|
|
537
|
+
const direct = fnNode.childForFieldName('declarator');
|
|
538
|
+
let cur = direct;
|
|
539
|
+
let hops = 8;
|
|
540
|
+
while (cur !== null && hops-- > 0) {
|
|
541
|
+
if (cur.type === 'function_declarator')
|
|
542
|
+
return cur;
|
|
543
|
+
if (cur.type === 'pointer_declarator' || cur.type === 'reference_declarator') {
|
|
544
|
+
cur = cur.childForFieldName('declarator');
|
|
545
|
+
continue;
|
|
546
|
+
}
|
|
547
|
+
break;
|
|
548
|
+
}
|
|
549
|
+
return findFirstDescendantOfType(fnNode, 'function_declarator');
|
|
550
|
+
}
|
|
487
551
|
/** Find the first direct child matching one of the given types. */
|
|
488
552
|
function findChildOfType(node, types) {
|
|
489
553
|
for (let i = 0; i < node.childCount; i++) {
|
|
@@ -589,6 +653,15 @@ function inferCppLiteralType(node) {
|
|
|
589
653
|
* - `int n = ...` → 'int'
|
|
590
654
|
* - `const int n = ...` → 'int'
|
|
591
655
|
* Returns empty string if no declaration found or type is auto/placeholder.
|
|
656
|
+
*
|
|
657
|
+
* Limitation: only `declaration` siblings inside the enclosing
|
|
658
|
+
* `compound_statement` are inspected. Function parameters live in the
|
|
659
|
+
* `function_declarator`'s `parameter_list` and are NOT resolved here, so
|
|
660
|
+
* `void run(int n) { process(n); }`
|
|
661
|
+
* infers `''` for `n` and the constraint filter falls through to
|
|
662
|
+
* `'unknown'` → ambiguity suppression → 0 CALLS edges. This is a
|
|
663
|
+
* "degrade not lie" gap (no wrong edges, just missing ones); extending
|
|
664
|
+
* the scan to `parameter_list` is tracked under #1579 as a follow-up.
|
|
592
665
|
*/
|
|
593
666
|
function lookupDeclaredTypeForIdentifier(identNode) {
|
|
594
667
|
const varName = identNode.text;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract C++ template constraint expressions for SFINAE-aware overload
|
|
3
|
+
* narrowing (issue #1579). Recognizes 3 AST shapes:
|
|
4
|
+
*
|
|
5
|
+
* F1 — unqualified non-type template param default:
|
|
6
|
+
* `template<class T, enable_if_t<P, int> = 0> void f(T);`
|
|
7
|
+
* F2 — `std::`-qualified variant (canonical ticket form):
|
|
8
|
+
* `template<class T, std::enable_if_t<P, int> = 0> void f(T);`
|
|
9
|
+
* F4 — C++20 leading requires-clause:
|
|
10
|
+
* `template<class T> requires P void f(T);`
|
|
11
|
+
*
|
|
12
|
+
* Deferred (return `{kind:'unknown'}`):
|
|
13
|
+
* F3 — void-default `typename = enable_if_t<P>` (cppref labels this
|
|
14
|
+
* `/* WRONG *\/` because adjacent overloads collapse to redeclarations)
|
|
15
|
+
* F5 — trailing requires (`void f(T) requires P;`)
|
|
16
|
+
* `requires_expression` blocks (`requires { typename T::U; }`)
|
|
17
|
+
* `decltype(...)`, fold-expressions, user-defined `_v` aliases.
|
|
18
|
+
*
|
|
19
|
+
* The output payload is opaque to shared code — only
|
|
20
|
+
* `constraint-filter.ts` consumes it. See ISO `[temp.constr.normal]` /
|
|
21
|
+
* `<https://en.cppreference.com/w/cpp/language/constraints>` for the
|
|
22
|
+
* normalization the Kleene 3-valued evaluator implements.
|
|
23
|
+
*/
|
|
24
|
+
import type { SyntaxNode } from '../../utils/ast-helpers.js';
|
|
25
|
+
export type ConstraintExpr = {
|
|
26
|
+
readonly kind: 'atomic';
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly args: readonly string[];
|
|
29
|
+
} | {
|
|
30
|
+
readonly kind: 'and';
|
|
31
|
+
readonly children: readonly ConstraintExpr[];
|
|
32
|
+
} | {
|
|
33
|
+
readonly kind: 'or';
|
|
34
|
+
readonly children: readonly ConstraintExpr[];
|
|
35
|
+
} | {
|
|
36
|
+
readonly kind: 'not';
|
|
37
|
+
readonly child: ConstraintExpr;
|
|
38
|
+
} | {
|
|
39
|
+
readonly kind: 'unknown';
|
|
40
|
+
};
|
|
41
|
+
export interface CppConstraintPayload {
|
|
42
|
+
/** Ordered template parameter names (type-params only — non-type defaults
|
|
43
|
+
* carrying enable_if predicates are folded into `expr`). */
|
|
44
|
+
readonly templateParams: readonly string[];
|
|
45
|
+
/**
|
|
46
|
+
* Mapping from each template parameter name to the call-site argument
|
|
47
|
+
* index where its deduced type lives. Computed by scanning the function's
|
|
48
|
+
* parameter list for the first parameter whose type is the bare template
|
|
49
|
+
* parameter name (or template-typed by it). Missing entries → 'unknown'
|
|
50
|
+
* verdict at evaluation time.
|
|
51
|
+
*/
|
|
52
|
+
readonly paramArgIndex: {
|
|
53
|
+
readonly [paramName: string]: number;
|
|
54
|
+
};
|
|
55
|
+
/** Root constraint expression. When multiple constraints (multiple
|
|
56
|
+
* enable_if defaults, requires clause, etc.) are present they are
|
|
57
|
+
* implicitly conjoined under a top-level `and` node. */
|
|
58
|
+
readonly expr: ConstraintExpr;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Walk a `template_declaration` AST node and extract its constraint
|
|
62
|
+
* payload. Caller is responsible for passing the OUTER `template_declaration`
|
|
63
|
+
* — for class-member template functions, that means the enclosing
|
|
64
|
+
* template_declaration of the class OR of the method, whichever
|
|
65
|
+
* directly precedes the function definition.
|
|
66
|
+
*
|
|
67
|
+
* Returns `undefined` when the template_declaration declares no
|
|
68
|
+
* constraints worth tracking (no enable_if default, no requires clause).
|
|
69
|
+
* Returns a payload whose `expr.kind === 'unknown'` when constraints are
|
|
70
|
+
* present but the extractor cannot model them — monotonicity guarantees
|
|
71
|
+
* the filter keeps the candidate in that case.
|
|
72
|
+
*/
|
|
73
|
+
export declare function extractCppTemplateConstraints(templateDecl: SyntaxNode, funcDeclarator: SyntaxNode | null): CppConstraintPayload | undefined;
|