Skip to content

Scala baseline parity, then SemanticDB semantic facts #1186

Description

@vitali87

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    advancedDifficult issueenhancementNew feature or requestscalaScala language

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions