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

Warn (or throw?) when a value class gets boxed #9504

Closed
scabug opened this issue Oct 5, 2015 · 5 comments
Closed

Warn (or throw?) when a value class gets boxed #9504

scabug opened this issue Oct 5, 2015 · 5 comments

Comments

@scabug
Copy link

scabug commented Oct 5, 2015

Proposal: Add a compiler flag that makes it easier to know when an AnyVal allocation occurs.

AnyVals can radically improve performance, but allocations can occur in surprising places (removing any performance gains). SIP-15 documents the conditions under which allocation occurs, but that can be hard to remember when browsing a complicated program. Compiler support for detecting allocations would help a lot.

A couple of possible flags are:

  • Warning - Generate a compiler warning when a use-site will require an AnyVal to be allocated.
  • Throw on Allocate - Add a flag that causes an exception to be thrown when an AnyVal is allocated. The resulting stack trace should allow the programmer to track down the allocation easily.
@scabug
Copy link
Author

scabug commented Oct 5, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9504?orig=1
Reporter: Justin Bailey (m4dc4p)

@SethTisue
Copy link
Member

@som-snytt did you do a thing like this under -Wperformance?

@SethTisue SethTisue changed the title Make AnyVals Easier To Use Warn (or throw?) when a value class gets boxed Feb 7, 2023
@som-snytt
Copy link

I see the linked (duplicating) ticket links to the -Wperformance PR which warns for Ref heapification which is not all boxing.

@som-snytt
Copy link

I'll let @SethTisue choose which ticket to close. It's nice to honor earlier reports, like being the first to name a species, but the other ticket has slightly more attention due its high-profile reporter.

@SethTisue SethTisue removed this from the Backlog milestone Feb 7, 2023
@SethTisue
Copy link
Member

consolidating at #12271

@SethTisue SethTisue closed this as not planned Won't fix, can't repro, duplicate, stale Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants