Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty package is available across files to named packages #13114

Closed
som-snytt opened this issue Jul 20, 2021 · 2 comments · Fixed by #13593
Closed

Empty package is available across files to named packages #13114

som-snytt opened this issue Jul 20, 2021 · 2 comments · Fixed by #13593
Assignees
Milestone

Comments

@som-snytt
Copy link
Contributor

Compiler version

Scala compiler version 3.0.3-RC1-bin-SNAPSHOT-git-7899462 -- Copyright 2002-2021, LAMP/EPFL

Minimized code

A file with definitions in empty package:

def f = 42

class C

Another file with definitions in named package:

class D2 extends C

package p {
  class D extends C

  @main def test = println((new D, new D2))
}

but it doesn't compile without the D2

package p {
  class D extends C

  @main def test = println(new D)
}

Output

without the "enabling" D2 to "open" the empty package

  ~/projects/dotty/bin/scalac -d /tmp -Vprint:typer  mt2.scala mt.scala
-- [E006] Not Found Error: mt.scala:5:18 --------------------------------------------------------------------------------
5 |  class D extends C
  |                  ^
  |                  Not found: type C

Expectation

File visibility of empty package defs in named package, per #7891

Not magically visible empty package across compilation units, such as C visible when D2 is defined.

Empty package defs available to empty package anywhere and anything in same file.

@som-snytt som-snytt changed the title Introducing empty package def makes empty package available across files to named packages Empty package is available across files to named packages Jul 20, 2021
@som-snytt
Copy link
Contributor Author

It looks like the "extra" definition could also be a second package, not just a top-level def.

@Kordyjan
Copy link
Contributor

The visibility of definitions from the empty package is still an unsolved issue. This one will probably be solved together with #7891, you have mentioned.

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

Successfully merging a pull request may close this issue.

3 participants