Skip to content

Tailrec for derivesFrom/lookupRefined/classSymbol/classSymbols #2043

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
Mar 15, 2017

Conversation

nicolasstucki
Copy link
Contributor

Fist two commits make changes to loops, the third only adds @tailrec annotations.

case pre: RefinedType =>
pre.refinedInfo match {
case TypeAlias(alias) =>
if (pre.refinedName ne name) loop(pre.parent) else alias
case _ => loop(pre.parent)
}
case pre: RecType =>
val candidate = loop(pre.parent)
val candidate = pre.parent.lookupRefined(name)
Copy link
Contributor

Choose a reason for hiding this comment

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

this change is not necessary. It will still get tail-rec optimized even without it.
You can use #1221 to mark per-callsite @tailrec-s

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I used it in several places. In this instance it was easier to use the old notation.

@@ -290,50 +290,56 @@ object Types {
* instance, or NoSymbol if none exists (either because this type is not a
* value type, or because superclasses are ambiguous).
*/
final def classSymbol(implicit ctx: Context): Symbol = this match {
case ConstantType(constant) =>
constant.tpe.classSymbol
Copy link
Contributor

Choose a reason for hiding this comment

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

wasn't this already tailrec optimized?
Instead of rewriting by hand I suggest using #1221

@nicolasstucki nicolasstucki force-pushed the tailrec-derivesFrom branch 3 times, most recently from 95db95a to b3835b5 Compare March 1, 2017 12:02
@DarkDimius
Copy link
Contributor

LGTM

@DarkDimius DarkDimius merged commit 141fb4b into scala:master Mar 15, 2017
@allanrenucci allanrenucci deleted the tailrec-derivesFrom branch December 14, 2017 19:24
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