You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
➜ scala -version
Starting scala3 REPL...
Dotty compiler version 3.0.0-M1--Copyright2002-2020, LAMP/EPFL
scala>objectModule {
|classMyInt(privatevalx:Int)
|objectMyInt {
|implicitclassOps(self: MyInt) extendsAnyVal {
|defx:Int= self.x
| }
| }
| }
// defined object Module
scala>importModule._
scala>vala=newMyInt(42)
vala:Module.MyInt=Module$MyInt@165aa43a
scala> a.x
1|a.x
|^^^|value x cannot be accessed asa member of (a : Module.MyInt) from module classrs$line$4$.
scala>MyInt.Ops(a).x
valres0:Int=42
Expectation
Because MyInt#x is private, a.x should resolve to the extension method defined by MyInt.Ops. That's how Scala 2 works. We used this pattern in scodec-bits to evolve the library without breaking binary compatibility -- in particular, scodec/scodec-bits#107 (comment).
The text was updated successfully, but these errors were encountered:
Minimized code
Expectation
Because
MyInt#x
is private,a.x
should resolve to the extension method defined byMyInt.Ops
. That's how Scala 2 works. We used this pattern in scodec-bits to evolve the library without breaking binary compatibility -- in particular, scodec/scodec-bits#107 (comment).The text was updated successfully, but these errors were encountered: