Skip to content

Protected object (sometimes) visible when it shouldn't #11554

Open
@dragos

Description

@dragos

When the access and the definition are compiled separately, Scala lets this one pass. When compiled together, it issues an error:

// file a.scala
package core.test

protected object Exec {
  def isBool: Boolean = false
}
// file b.scala
package bar

import core.test._

class Test {
  Exec.isBool // Exec should not be visible here
}

Compiling these two together gives the expected error:

visibility2.scala:6: error: not found: value Exec
  Exec.isBool // Exec should not be visible here
  ^
one error found

Compiling one and then the other succeeds, though:

$ scalac -d /tmp/classes/ a.scala 
$ scalac -d /tmp/classes/ -cp /tmp/classes/ b.scala 
$

Scala version: 2.12.8

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions