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

SI-6574 Support @tailrec for extension methods. #2717

Merged
merged 1 commit into from Jul 10, 2013

Conversation

retronym
Copy link
Member

@retronym retronym commented Jul 9, 2013

Currently, when the body of an extension method is transplanted
to the companion object, recursive calls point back to the original
instance method. That changes during erasure, but this is too late
for tail call analysis/elimination.

This commit eagerly updates the recursive calls to point to the
extension method in the companion. It also removes the @tailrec
annotation from the original method.

Review by @adriaanm

@retronym
Copy link
Member Author

retronym commented Jul 9, 2013

Hmmm.

[quick.repl] Compiling 48 files to /localhome/jenkins/a/workspace/pr-rangepos-per-commit/build/quick/classes/repl
[quick.repl] error: Unknown type: <notype>, <notype> [class scala.reflect.internal.Types$NoType$, class scala.reflect.internal.Types$NoType$] TypeRef? false
[quick.repl] error: scala.reflect.internal.FatalError: Unknown type: <notype>, <notype> [class scala.reflect.internal.Types$NoType$, class scala.reflect.internal.Types$NoType$] TypeRef? false
[quick.repl]    at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:53)
[quick.repl]    at scala.tools.nsc.Global.abort(Global.scala:256)
[quick.repl]    at scala.tools.nsc.backend.icode.TypeKinds$class.toTypeKind(TypeKinds.scala:401)
[quick.repl]    at scala.tools.nsc.backend.icode.ICodes.toTypeKind(ICodes.scala:18)
[quick.repl]    at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genLoadApply1$1(GenICode.scala:607)
[quick.repl]    at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:634)
[quick.repl]    at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genLoadQualifier(GenICode.scala:1080)
[quick.repl]    at scala.tools.nsc.backend.icode.GenICode$ICodePhase.genLoadApply6$1(GenICode.scala:773)

Shutting this one down for now.

@retronym retronym closed this Jul 9, 2013
Currently, when the body of an extension method is transplanted
to the companion object, recursive calls point back to the original
instance method. That changes during erasure, but this is too late
for tail call analysis/elimination.

This commit eagerly updates the recursive calls to point to the
extension method in the companion. It also removes the @tailrec
annotation from the original method.
@retronym retronym reopened this Jul 10, 2013
@@ -264,4 +266,33 @@ abstract class ExtensionMethods extends Transform with TypingTransformers {
stat
}
}

final class SubstututeRecursion(origMeth: Symbol, extensionMeth: Symbol,
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the u-u-u sound, but u-i-u is generally more accepted. Anyway, can be fixed some other day.

@adriaanm
Copy link
Contributor

LGTM

adriaanm added a commit that referenced this pull request Jul 10, 2013
SI-6574 Support @tailrec for extension methods.
@adriaanm adriaanm merged commit 5994711 into scala:master Jul 10, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants