-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Recursive references in objects #16456
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
Comments
Compare #16152 The class initializer for the top-level object leaks its Local and member objects are lazy vals. |
@liufengyun It warns about example 2 but not about example 3. |
You mean the 1st example gets a warning? For the 2nd and 3rd, the objects are not global objects. |
The 1st example gets a warning. We all agree on that. The 2nd example doesn't even compile: For the 3rd example neither checker (neither |
I took example 2 to mean local (not a member of a class or package).
Is example 3 a loop or rather deadlock on class initialization. |
As it's given, there are no threads, so it's non-termination. If we access |
Compiler version
3.2.0
Minimized code
The first example works (I believe) correctly. I would expect the latter two to have the same output, yet the second one results in stack overflow and the third one loops infinitely.
Example 1:
https://scastie.scala-lang.org/TWhOPNLMTYyAV18EqK6hLA
Output
(this is correct)
Example 2:
https://scastie.scala-lang.org/Wki4Z9XJR3Gx13RFmCzpXQ
Output
Expectation
Example 3:
https://scastie.scala-lang.org/347k71gqSXuZhtZLOK69yQ
Output
(no output, loops infinitely)
Expectation
The text was updated successfully, but these errors were encountered: