Skip to content

Top-level definitions in Scala are not found #23023

@mrdziuban

Description

@mrdziuban

Describe the bug

Repository that reproduces the issue: https://github.com/mrdziuban/pants-scala-top-level-test

I setup a Pants build with two Scala files:

  1. src/main/scala/example/Foo.scala with contents
    package example
    val foo = "foo"
  2. src/main/scala/example/Bar.scala with contents
    package example
    val bar = foo

When I compile the project with pants check :: I get an error:

-- [E006] Not Found Error: main/scala/example/Bar.scala:2:10 -------------------
2 |val bar = foo
  |          ^^^
  |          Not found: foo

However if I modify Foo.scala to place val foo inside an object then everything works properly, so I believe the problem has to do with the top-level definition.

Pants version

2.30.0

OS

MacOS, I haven't tested on Linux.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions