Skip to content

Fix #3478: Optimize away unused defs and lazy vals #3840

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 18, 2018

Conversation

nicolasstucki
Copy link
Contributor

No description provided.

@@ -159,6 +159,9 @@ class Devalify extends Optimisation {
if (replacements.contains(t.symbol))
deepReplacer.transform(replacements(t.symbol)).ensureConforms(t.tpe.widen)
else t
case t: DefDef if timesUsed.getOrElse(t.symbol, 0) == 0 =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this remove only local definitions? Otherwise, it is not safe to remove public members and definitions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the Simplifier only transforms local trees.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But you are right. We still have inner classes. I will fix that.

Copy link
Contributor

@OlivierBlanvillain OlivierBlanvillain left a comment

Choose a reason for hiding this comment

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

LGTM.

I just tried and unused val/def in inner classes are not optimized away by these changes, maybe we should add a neg test?

@nicolasstucki nicolasstucki merged commit f90da9e into scala:master Jan 18, 2018
@allanrenucci allanrenucci deleted the fix-#3478 branch January 18, 2018 08:54
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.

3 participants