Skip to content

Avoid printing extra blocks and inline nodes #5510

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

Conversation

nicolasstucki
Copy link
Contributor

Avoid printing extra blocks and inline nodes

@nicolasstucki nicolasstucki changed the title Avoidprinting-nested-empty-blocks Avoid printing extra blocks and inline nodes Nov 24, 2018
@nicolasstucki nicolasstucki force-pushed the avoid-printing-nested-empty-blocks branch from 5fe2c2c to ca35eee Compare November 24, 2018 07:48
@nicolasstucki nicolasstucki force-pushed the avoid-printing-nested-empty-blocks branch 10 times, most recently from e74e9d4 to 52dddce Compare November 24, 2018 16:42
@nicolasstucki nicolasstucki force-pushed the avoid-printing-nested-empty-blocks branch from 52dddce to 0bc7db4 Compare November 30, 2018 07:27
@nicolasstucki
Copy link
Contributor Author

Rebased

Avoid printing extra blocks and inline nodes
@nicolasstucki nicolasstucki force-pushed the avoid-printing-nested-empty-blocks branch from 0bc7db4 to 0dc0587 Compare December 6, 2018 07:24
@nicolasstucki
Copy link
Contributor Author

Rebased

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.

Otherwise, LGTM

@@ -777,34 +788,13 @@ trait Printers
case IsValDef(tree) => !tree.symbol.flags.isObject
case _ => true
}
printFlatBlock(stats, expr)
Copy link
Contributor

Choose a reason for hiding this comment

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

The code seems to have forgotten the case implicit object A.

extractFlatStats(it.next())
val flatExpr = extractFlatExpr(expr)
(flatStats.result(), flatExpr)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Code smell for flatBlock: is there a way to simplify the code and logic?

val init :+ last = stats2
(init, last)
case _ => (stats2, expr1)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The Remove Term.Lambda logic seems to belong to somewhere else .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the decompiler, Term.Lambda are no-op/no-print trees that must be removed from the blocks. We need to remove them here because they might affect the block flattening.

@nicolasstucki nicolasstucki merged commit 909f10a into scala:master Dec 6, 2018
@nicolasstucki nicolasstucki deleted the avoid-printing-nested-empty-blocks branch December 6, 2018 12:27
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