Skip to content

private types escape via bounds #4739

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

Open
scabug opened this issue Jun 26, 2011 · 4 comments
Open

private types escape via bounds #4739

scabug opened this issue Jun 26, 2011 · 4 comments

Comments

@scabug
Copy link

scabug commented Jun 26, 2011

This is in 2.9, so not recent.

private[scala] trait SpecializableCompanion
private[scala] trait AnyValCompanion extends SpecializableCompanion { }

scala> List(Byte, Char, Short)
res0: List[AnyValCompanion with ScalaObject] = List(object scala.Byte, object scala.Char, object scala.Short)

scala> var x: List[AnyValCompanion with ScalaObject] = res0
<console>:8: error: trait AnyValCompanion cannot be accessed in package scala
       var x: List[AnyValCompanion with ScalaObject] = res0
                   ^
@scabug
Copy link
Author

scabug commented Jun 26, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4739?orig=1
Reporter: @paulp

@hrhino
Copy link

hrhino commented Mar 3, 2018

2.9 is so not recent.

@SethTisue
Copy link
Member

SethTisue commented Mar 3, 2018

same in 2.12.4:

scala> :paste -raw
package a                                                                                                               
private[a] trait T                                                                                                      
trait T1 extends T                                                                                                      
trait T2 extends T

scala> List(new a.T1 {}, new a.T2 {})
res1: List[a.T] = List($anon$1@5626d18c, $anon$2@45e9b12d)

scala> res1: List[a.T]
<console>:13: error: trait T in package a cannot be accessed in package a
       res1: List[a.T]
                    ^

but, I don't see why this would be considered a bug. what should happen instead?

@paulp
Copy link

paulp commented Mar 3, 2018

@SethTisue Because it makes no sense to infer inaccessible types.

A: "These are Dingos."
B: "Oh, thanks, I wasn't sure what they were. Give me the first Dingo then."
A: "WHAT'S A DINGO?"

Here, it should infer List[AnyRef], not List[type-you-cannot-even-reference].

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

No branches or pull requests

4 participants