Skip to content

Script filename (doodle.sc) shadows dependency package (doodle) — possible scala-cli naming collision #4285

@jvr-ks

Description

@jvr-ks

Environment

scala-cli: 1.14.0
Scala: 3.8.3
JVM: Temurin 21
OS: Windows 10
Dependency: org.creativescala:doodle-core_3:0.34.0

Description
A script file named doodle.sc causes imports from the doodle dependency to be shadowed. Importing doodle.core._ fails with "value core is not a member of doodle". Renaming the script (e.g., doodle1.sc) fixes the issue. This only occurs for scripts.

Minimal reproduction (copy-paste)

File: doodle.sc

//> using dep "org.creativescala::doodle-core:0.34.0"
import doodle.core._
println("repro")

Command: scala-cli run -S 3 doodle.sc --jvm temurin:21

Observed

Compilation fails with: "value core is not a member of doodle$_"

Expected

The import should resolve to the package inside the downloaded JAR and script should compile and run (print "repro"). Script filename must not create a generated symbol that shadows dependency packages.

Notes / diagnosis

Renaming the file to doodle1.sc immediately resolves the problem.
Likely cause: scala-cli generates a wrapper package/object from the script filename that collides with dependency package names, and that generated symbol takes precedence in name resolution.

Requested additional info for triage

Full compiler error output (including any stack trace)
Output of: scala-cli -v run -S 3 doodle.sc --jvm temurin:21
Any generated wrapper file contents or temp build artifacts (if accessible)

Suggested investigation

Verify how script filenames are converted to generated package/object names.
Confirm name-resolution precedence between generated wrapper code and classpath packages.
Add a regression test for script filename ↔ package name collisions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions