Skip to content

Scala/Rust brace-selector imports split before the prefix is distributed (a.b.{C, D} → a.b. C, D): Scala import recall 33% #3595

Description

@squid-protocol

Problem

galaxyscope.extract_raw_imports handles a brace-selector import by deleting the braces and then splitting on commas. So

import io.circe.{ Decoder, Json }

records the tokens io.circe. Decoder (with a space) and a bare Json. Neither resolves: the first carries a space, and the second has lost its package. Rust's use a::{b, c} goes through the same code.

Measured

tests/tools/import_graph_accuracy.py scala (circe/circe, added in #3594): precision 99.4%, recall 33.0%, 674 missed imports. Examples from TodoService.scala and AtBenchmark.scala:

  • io.circe.{ DecodingFailure, Errors } → Errors and io.circe. DecodingFailure
  • io.circe.{ Decoder, Json } → Json and io.circe. Decoder

Fix direction

In extract_raw_imports, expand prefix{a, b => c, _} into prefix + each selector before the comma split:

  • the prefix is everything before {, keeping its trailing . or ::;
  • b => c keeps b;
  • _ and * are wildcards.

This helps both Scala and Rust. Some of the remaining Scala misses are wildcard imports of package objects (io.circe.syntax._ → syntax/package.scala), which need a resolver rule; check them with --samples after the split fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUnintended behavior or logic failure in the enginecore-engineModifications to the central physics and parsing engine

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions