Skip to content

Better cast elision, fix an issue with tailrec #8713

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 2 commits into from
Apr 14, 2020

Conversation

smarter
Copy link
Member

@smarter smarter commented Apr 13, 2020

No description provided.

smarter added 2 commits April 13, 2020 02:22
We can get rid of `asInstanceOf[T]` whenever the erased type of
expression is a subtype of T. This allows us to produce leaner bytecode
and also fixes scala#8712 since unnecessary asInstanceOf calls were
preventing tailrec from working.
- Avoid using the generic Array constructor when possible
- In the situation where we do need to use the generic Array
  constructor, add an expected type to make the example more realistic
  and reveal whether a checkcast is needed in bytecode to make use
  of the Array at all.

With these changes, using Array or IArray produce the exact same
bytecode.
@nicolasstucki nicolasstucki merged commit 37006e3 into scala:master Apr 14, 2020
@nicolasstucki nicolasstucki deleted the cast-elision branch April 14, 2020 05:26
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.

2 participants