Skip to content
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

Map class literal constant types #16988

Merged
merged 1 commit into from
Feb 24, 2023
Merged

Conversation

dwijnand
Copy link
Member

Fixes #16954

tests/neg/i16954.scala Outdated Show resolved Hide resolved
compiler/src/dotty/tools/dotc/core/TypeOps.scala Outdated Show resolved Hide resolved
@dwijnand dwijnand assigned smarter and unassigned nicolasstucki Feb 24, 2023
@dwijnand dwijnand removed the request for review from nicolasstucki February 24, 2023 13:31
@dwijnand dwijnand changed the title Avoid in ConstantTypes Make class literals constant types Feb 24, 2023
@dwijnand dwijnand changed the title Make class literals constant types Map class literals constant types Feb 24, 2023
case ast.TreeInfo.Impure => "PurityLevel.Impure"
case ast.TreeInfo.PurePath => "PurityLevel.PurePath"
case ast.TreeInfo.IdempotentPath => "PurityLevel.IdempotentPath"
case _ => s"PurityLevel(${x.x})"
Copy link
Member Author

Choose a reason for hiding this comment

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

I was looking at

        val countsAsPure =
          if dropOp(tree1).symbol.isInlineVal
          then isIdempotentExpr(tree1)
          else isPureExpr(tree1)

in constToLiteral and needed to print purity levels.

Copy link
Member

Choose a reason for hiding this comment

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

Could this be achieved by making PurityLevel an enum instead to generate a sensible toString?

Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps. But what's a nice way to reimplement min?

Copy link
Member

Choose a reason for hiding this comment

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

Ah I hadn't considered that, nevermind then.

Copy link
Member

Choose a reason for hiding this comment

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

This could still be implemented as the toString of PurityLevel since it doesn't require a Context.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, it could.

@dwijnand dwijnand changed the title Map class literals constant types Map class literal constant types Feb 24, 2023
Copy link
Member

@smarter smarter 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.

case ast.TreeInfo.Impure => "PurityLevel.Impure"
case ast.TreeInfo.PurePath => "PurityLevel.PurePath"
case ast.TreeInfo.IdempotentPath => "PurityLevel.IdempotentPath"
case _ => s"PurityLevel(${x.x})"
Copy link
Member

Choose a reason for hiding this comment

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

Could this be achieved by making PurityLevel an enum instead to generate a sensible toString?

@smarter smarter assigned dwijnand and unassigned smarter Feb 24, 2023
@dwijnand dwijnand merged commit c1809bc into scala:main Feb 24, 2023
@dwijnand dwijnand deleted the avoid-constant-types branch February 24, 2023 22:39
@Kordyjan Kordyjan added this to the 3.3.1 milestone Aug 1, 2023
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.

AssertionError: assertion failed: leak
4 participants