Skip to content

Check access rights of objects in import selectors #23081

Open
@hamzaremmal

Description

@hamzaremmal

Compiler version

c4531d4

Minimized code

package bar:
  private[bar] object Bar

package foo:
  import bar.Bar   // no error
  val _ =  Bar     // error: not found (import is a no-op)
  val _ =  bar.Bar // error: access modifier

Output

-- [E006] Not Found Error: minim.scala:6:11 ------------------------------------
6 |  val _ =  Bar // error: not found (import is a no-op)
  |           ^^^
  |           Not found: Bar
  |
  | longer explanation available when compiling with `-explain`
-- [E173] Reference Error: minim.scala:7:15 ------------------------------------
7 |  val _ =  bar.Bar // error: access modifier
  |           ^^^^^^^
  |object Bar cannot be accessed as a member of bar.type from the top-level definitions in package foo.
  |  private[bar] object Bar can only be accessed from package bar.
2 errors found

Expectation

Have an error when importing an object that is not accessible from the current scope

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions