Skip to content

Fix #7434: Tighten a condition in LazyVals #7435

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 3 commits into from
Oct 26, 2019

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Oct 18, 2019

No description provided.

@odersky odersky changed the title Fix #7434 Fix #7434: Tighten a condition in LazyVals Oct 18, 2019
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

LGTM

Just a minor comment below for consideration.

// For non-private trait members we can check whether there is an overridden symbol.
// For private trait members this does not work, since `ensureNotPrivate` in phase Mixins
// does change the name but does not update the owner's scope, so `allOverriddenSymbols` does
// not work in that case. However, we can check whether the name is an ExpandedName instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the code is a little brittle.

The optimization was introduced in 8f47f16 to fix #676 . Since #4090, we no longer generate companion objects in FirstTransform anymore, it seems we can just disable the optimization.

If the optimization is needed, what about using a compiler flag to flag an object as eager, and we only check flags here? That flag could also be reused to enable more optimization opportunities without worrying about semantic problems.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even with automatic generation of companion objects disabled, I believe there are still a lot of them, so it's worthwhile to optimize. But the criterion as it stands is somewhat arbitrary and could be improved. E.g. we could also strictify companion objects that are pure.

@odersky odersky merged commit 675779e into scala:master Oct 26, 2019
@odersky odersky deleted the fix-#7434 branch October 26, 2019 10:58
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