-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Non-stable lazy val pattern bindings #18878
Comments
It works wth object Foo {
val (a, (b, c), d) = (1, (2, 3), 4)
def a2: a.type = a
}
|
This issue was found when trying by using TASTy MiMa on the Scala 2 library TASTy. |
Maybe the |
Fixes scala#18878 Reverts change in 54f6399 Example: ``` lazy val (a, b) = ... ``` desugars into ``` private lazy val t$1 = ... lazy val a = t$1._1 // before: def a = t$1._1 lazy val b = t$1._2 // before: def b = t$1._2 ``` Where `a` and `b` should be stable identifiers.
That seems expected to me. scala> class Foo { lazy val a = "foo"; def b: a.type = a }
-- Error: ----------------------------------------------------------------------
1 |class Foo { lazy val a = "foo"; def b: a.type = a }
| ^
| (Foo.this.a : String) is not a legal path
| since it refers to nonfinal lazy value a
1 error found |
I the case I showed I have an object Bar { lazy val a = "foo"; def b: a.type = a } |
As I wrote in my comment to #18879, maybe that should not work either. |
Then I will only focus on what we should do in the Scala 2 library case. It seems I should apply the fix in #18879 on the when compiling. But maybe we could just leave it as it is if it does not cause incompatibilities in practice. I will investigate. |
The problematic case in the library is |
Compiler version
3.0 - 3.3
Minimized code
Output
Note that the syntax tree creates
def
for the bindings instead oflazy val
s.Scala 2.13 desugaring
Expectation
This should compile
The text was updated successfully, but these errors were encountered: