Skip to content

Conversation

@gan74
Copy link
Contributor

@gan74 gan74 commented Nov 13, 2017

Expressions with constant type are now folded correctly.
ConstantFold doesn't call typer's ConstFold.apply on every expression making it faster.
if(!e) { a } else { b } is now transformed into if(e) { b } else { a }

Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

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

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Have an awesome day! ☀️

@DarkDimius
Copy link
Contributor

DarkDimius commented Nov 13, 2017 via email

// cond.select(defn.Boolean_&&).appliedTo(elsep)
// the other case ins't handled intentionally. See previous case for explanation

case If(t @ Select(recv, _), thenp, elsep) if t.symbol eq defn.Boolean_! =>
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused, in the PR description you say that if(!e) { a } else { b } now if(e) { b } else { a }, but it seams that you just removed the case doing that... Could you had a test for this example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, I looked into it: you are right. It's an error on my part, I didn't add the feature, I only added documentation for it.

Sorry or the confusion...

Expressions with constant type are now folded correctly.
ConstantFold doesn't call typer's ConstFold.apply on every expression making it faster
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!

@gan74 gan74 changed the title WIP: Constant folding improvements Constant folding improvements Nov 15, 2017
@allanrenucci allanrenucci merged commit b76358f into scala:master Nov 20, 2017
@gan74 gan74 deleted the wip-local-opt branch December 13, 2017 22:31
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.

5 participants