Skip to content

Fix #3624: Lazily evaluate static module accessors #3719

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

Merged
merged 2 commits into from
Jan 13, 2018

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Dec 31, 2017

We did not use lazy evaluation for static objects, because these are usually evauated
lazily by the backend. But that does not hold if the static module is an (accessor) def
instead of a val.

We did not use lazy evaluation for static objects, because these are usually evauated
lazily by the backend. But that does not hold if the static module is an (accessor) def
instead of a val.
@odersky odersky requested a review from DarkDimius December 31, 2017 15:15
@smarter
Copy link
Member

smarter commented Dec 31, 2017

The issue number referenced in the commit message is wrong, it should be #3624, not #3634

if (!(sym is Flags.Lazy) ||
sym.owner.is(Flags.Trait) ||
(sym.isStatic && sym.is(Flags.Module, butNot = Flags.Method)))
tree
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment here explaining why this is OK in these cases?


object Test {
def main(args: Array[String]): Unit = {
assert(Bar.Foo == Bar.Foo) // false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use eq instead of == to be extra sure that nothing funny is going on.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add a object Baz extends T and assert(Bar.Foo ne Baz.Foo)

@odersky odersky changed the title Fix #3634: Lazily evaluate static module accessors Fix #3624: Lazily evaluate static module accessors Dec 31, 2017
@odersky odersky merged commit f802abf into scala:master Jan 13, 2018
@allanrenucci allanrenucci deleted the fix-#3634 branch January 14, 2018 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants