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

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

Open
dragos opened this issue Jun 3, 2019 · 1 comment

Comments

Projects
None yet
3 participants
@dragos
Copy link

commented Jun 3, 2019

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

dragos added a commit to dragos/incubator-openwhisk that referenced this issue Jun 4, 2019

Make Exec public since it's being used from tests.
The call to Exec.isBinaryCode in ActionContainer.scala is from a different package and normally not visible at the call site. Due to scala/bug#11554 this may compile sometimes.

@dragos dragos referenced this issue Jun 4, 2019

Merged

Fix a few compilation accidents #4505

1 of 21 tasks complete

dragos added a commit to dragos/incubator-openwhisk that referenced this issue Jun 4, 2019

Make Exec public since it's being used from tests.
The call to Exec.isBinaryCode in ActionContainer.scala is from a different package and normally not visible at the call site. Due to scala/bug#11554 this may compile sometimes.

rabbah added a commit to apache/incubator-openwhisk that referenced this issue Jun 4, 2019

Fix a few compilation accidents (#4505)
* Add explicit return type on a few implicit values.

Implicit values without an explicit return types are not guaranteed to work. They may or may not compile, depending on compilation order and they are going to be disallowed in future versions of Scala. This confuses IntelliJ as well.

* Make Exec public since it's being used from tests.

The call to Exec.isBinaryCode in ActionContainer.scala is from a different package and normally not visible at the call site. Due to scala/bug#11554 this may compile sometimes.
@hrhino

This comment has been minimized.

Copy link
Member

commented Jun 5, 2019

That's unfortunate. The problem is that this protected is less restrictive than the JVM's, so it's ACC_PUBLIC in bytecode, so the fact that it's protected isn't known until it's unpickled, and it's not unpickled until the Ident("Exec") tree is already typechecked (access-checked).

@SethTisue SethTisue changed the title Protected object (sometimes) visibile when it shouldn't Protected object (sometimes) visible when it shouldn't Jun 5, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.