mirror of
https://github.com/colbymchenry/codegraph.git
synced 2026-10-29 06:46:49 +08:00
fix(scala): a symbolic name in a type is a type, never an operator (#2217)
A kind-projector placeholder (`Align[Either[A, *]]`, `Functor[Map[K, ?]]`) reached the resolver as a type reference named `*`, and exact or fuzzy matching bound it to the one `*` in the project - algebra's `Signed.Sign.*` operator - 567 times in cats. A symbolic name in a Scala type now resolves only to a type or type alias of that name (cats' `F ~> G`), and otherwise to nothing, whatever strategy runs. cats -567; sttp unchanged. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a8b578f7d8
commit
fa43e259b2
@@ -4308,7 +4308,9 @@ export function matchByExactName(
|
||||
// A Scala type position (`Arbitrary[B]`) never names a method: an
|
||||
// `implicit def A: Order[A]` shares its name with half of cats' type
|
||||
// parameters. Scala's value references only read a file's own vals.
|
||||
!(ref.language === 'scala' && ref.referenceKind === 'references' && /^[A-Z]/.test(ref.referenceName) &&
|
||||
// Nor does a kind-projector placeholder (`F[*]`, `G[?]`): cats' 567 `*`
|
||||
// type arguments went to an algebra `Sign`'s `*` method.
|
||||
!(ref.language === 'scala' && ref.referenceKind === 'references' && /^(?:[A-Z]|[^\w\s]+$)/.test(ref.referenceName) &&
|
||||
(n.kind === 'method' || n.kind === 'function')) &&
|
||||
// Type/value references retain same-family eligibility: a native namesake
|
||||
// must not hide the actual web type. Calls still gate only the winner.
|
||||
@@ -8278,6 +8280,14 @@ function matchReferenceInner(
|
||||
return null;
|
||||
}
|
||||
|
||||
// A symbolic name in a Scala type is a type (`F ~> G`) or a kind-projector
|
||||
// placeholder (`Either[A, *]`) — never an operator method, by any strategy.
|
||||
if (ref.language === 'scala' && ref.referenceKind === 'references' && /^[^\w\s]+$/.test(ref.referenceName)) {
|
||||
const types = context.getNodesByName(ref.referenceName).filter((n) => n.language === 'scala' && (SCALA_TYPE_KINDS.has(n.kind) || n.kind === 'type_alias'));
|
||||
const chosen = types.length > 1 ? preferCallSiteFile(types, ref.filePath) : types;
|
||||
return chosen.length === 1 ? { original: ref, targetNodeId: chosen[0]!.id, confidence: 0.8, resolvedBy: 'exact-match' } : null;
|
||||
}
|
||||
|
||||
// A bare Lua call through a `local` alias reaches what the alias names.
|
||||
if ((ref.language === 'lua' || ref.language === 'luau') && ref.referenceKind === 'calls' && /^[A-Za-z_]\w*$/.test(ref.referenceName)) {
|
||||
const aliased = luaAliasTarget(ref, context);
|
||||
|
||||
Reference in New Issue
Block a user