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
While this compiles correctly in Scala 2.11.8, I'm getting the following error in Scala 2.12.0:
[error] /scala-test/test.scala:14: value x is not a member of A
[error] println(obj.x)
I read the breaking changes in Scala 2.12 release notes and I couldn't find anything related to this. I tried adding more fields and methods to MyTrait to be sure SAM conversions wouldn't apply, but the error persists.
Is this an intended breaking change or a bug? Is there an workaround?
The text was updated successfully, but these errors were encountered:
@SethTisue said (edited on Nov 12, 2016 4:31:28 PM UTC):
"Concretely, when computing the type of an overriding field, the type of the overridden field is used as the expected type. As a result, the inferred type of a val or lazy val may change in Scala 2.12." http://scala-lang.org/news/2.12.0
In your example, the type of the lazy val is simply A. If you want the structural type, you can explicitly declare it:
Consider this minimal example:
While this compiles correctly in Scala 2.11.8, I'm getting the following error in Scala 2.12.0:
I read the breaking changes in Scala 2.12 release notes and I couldn't find anything related to this. I tried adding more fields and methods to
MyTrait
to be sure SAM conversions wouldn't apply, but the error persists.Is this an intended breaking change or a bug? Is there an workaround?
The text was updated successfully, but these errors were encountered: