Skip to content

Fix #8843: Normalize type when constant folding #8852

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 1 commit into from
May 2, 2020

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented May 1, 2020

Also fixes #8854

@nicolasstucki nicolasstucki marked this pull request as draft May 1, 2020 08:18
@nicolasstucki nicolasstucki self-assigned this May 1, 2020
@nicolasstucki nicolasstucki linked an issue May 1, 2020 that may be closed by this pull request
@nicolasstucki nicolasstucki linked an issue May 1, 2020 that may be closed by this pull request
@nicolasstucki nicolasstucki marked this pull request as ready for review May 1, 2020 13:28
@nicolasstucki nicolasstucki requested a review from liufengyun May 1, 2020 13:28
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

Maybe also add the test case from #8842

@@ -510,7 +510,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
*/
def constToLiteral(tree: Tree)(implicit ctx: Context): Tree = {
val tree1 = ConstFold(tree)
tree1.tpe.widenTermRefExpr.dealias match {
tree1.tpe.widenTermRefExpr.dealias.normalized match {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
tree1.tpe.widenTermRefExpr.dealias.normalized match {
tree1.tpe.widenTermRefExpr.normalized match {

I'm wondering if it will make a difference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does not work without the dealiasing

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should refine normalized.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@OlivierBlanvillain should normalized dealias?

@nicolasstucki
Copy link
Contributor Author

This did not fix #8842

@nicolasstucki nicolasstucki merged commit 1f9bca3 into scala:master May 2, 2020
@nicolasstucki nicolasstucki deleted the fix-#8843 branch May 2, 2020 06:18
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.

Make local inline vals effectively erased. Inlined inline val reference does not get constant folded
2 participants