Why
Scala is the emptiest slot in the language matrix: no LanguageHandler registration, no import parsing, no type inference, no parsers/scala/ package — only FQN node-type tuples in constants/fqn_specs.py:363-508 and a single infix-operator special case at call_processor.py:2616. The support matrix marks it In Development.
Scala is also the language where heuristics have the lowest ceiling: implicits, extension methods, and for-comprehension desugaring are compiler transformations — no syntactic analysis will ever resolve them.
Plan — two stages
Stage 1: baseline tree-sitter parity
Bring Scala up to what every other language already has:
LanguageHandler registration + parsers/scala/ package
- Import parsing:
import a.b.c, wildcard _/*, selector groups and renames (import a.{B => C}), Scala 3 given imports
- Definitions:
object (and its companion pairing), case classes, traits, given/extension (Scala 3), nested defs
- INHERITS/IMPLEMENTS from
extends ... with ... clauses (trait linearization at least recorded, even if unresolved)
This unblocks the Scala FLOWS_TO descriptor issue and makes the existing scala_retrieval eval meaningful.
Stage 2: SemanticDB semantic facts
SemanticDB is purpose-built for exactly this use case — it's the format Metals runs on, and evals/oracles/scala_oracle/ already consumes scalameta:
- Scala 3 emits it with a compiler flag (
-Xsemanticdb); Scala 2 via the semanticdb-scalac compiler plugin.
- Each
.semanticdb file contains resolved symbol occurrences for every identifier: implicit resolutions, extension-method binding, desugared for-comprehensions, overload selection.
- Adapter: parse the protobuf payloads, map occurrences to
LanguageFrontend fact families (resolved_call_sites, external_sites, base_kinds by symbol, expression_types from signatures).
Friction: SemanticDB requires a compile via sbt/bloop/mill, so stage 2 is strictly opt-in — point CGR at the build's META-INF/semanticdb output directory, or run sbt compile behind a flag. A missing build degrades to stage 1 behaviour.
Tests
Fixture Scala repo per stage: stage 1 — imports with renames, companion objects, trait mixins; stage 2 — an implicit conversion, an extension method call, a for-comprehension over a custom monad, overloads. Cross-check calls against run_scala_call_oracle.
Stage 2 depends on the LanguageFrontend protocol issue.
Why
Scala is the emptiest slot in the language matrix: no
LanguageHandlerregistration, no import parsing, no type inference, noparsers/scala/package — only FQN node-type tuples inconstants/fqn_specs.py:363-508and a single infix-operator special case atcall_processor.py:2616. The support matrix marks it In Development.Scala is also the language where heuristics have the lowest ceiling: implicits, extension methods, and for-comprehension desugaring are compiler transformations — no syntactic analysis will ever resolve them.
Plan — two stages
Stage 1: baseline tree-sitter parity
Bring Scala up to what every other language already has:
LanguageHandlerregistration +parsers/scala/packageimport a.b.c, wildcard_/*, selector groups and renames (import a.{B => C}), Scala 3givenimportsobject(and its companion pairing), case classes, traits,given/extension(Scala 3), nested defsextends ... with ...clauses (trait linearization at least recorded, even if unresolved)This unblocks the Scala FLOWS_TO descriptor issue and makes the existing
scala_retrievaleval meaningful.Stage 2: SemanticDB semantic facts
SemanticDB is purpose-built for exactly this use case — it's the format Metals runs on, and
evals/oracles/scala_oracle/already consumes scalameta:-Xsemanticdb); Scala 2 via thesemanticdb-scalaccompiler plugin..semanticdbfile contains resolved symbol occurrences for every identifier: implicit resolutions, extension-method binding, desugared for-comprehensions, overload selection.LanguageFrontendfact families (resolved_call_sites, external_sites, base_kinds by symbol, expression_types from signatures).Friction: SemanticDB requires a compile via sbt/bloop/mill, so stage 2 is strictly opt-in — point CGR at the build's
META-INF/semanticdboutput directory, or runsbt compilebehind a flag. A missing build degrades to stage 1 behaviour.Tests
Fixture Scala repo per stage: stage 1 — imports with renames, companion objects, trait mixins; stage 2 — an implicit conversion, an extension method call, a for-comprehension over a custom monad, overloads. Cross-check calls against
run_scala_call_oracle.Stage 2 depends on the
LanguageFrontendprotocol issue.