Skip to content

Empty package is available across files to named packages #13114

Closed
@som-snytt

Description

@som-snytt

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions