aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/transform/SymUtils.scala
diff options
context:
space:
mode:
authorDmitry Petrashko <dark@d-d.me>2017-03-15 10:04:20 +0100
committerGitHub <noreply@github.com>2017-03-15 10:04:20 +0100
commit141fb4b8c63e5b9cbbb1b92f55412e676a38cbf0 (patch)
treecab94bb63bad887672534d4d3f078506a0a9ce59 /compiler/src/dotty/tools/dotc/transform/SymUtils.scala
parent934da77590dad2003fe850b48b2ae01b427508f0 (diff)
parentbe5720c18ca6768c7e72d4258677952848db2bb4 (diff)
downloaddotty-141fb4b8c63e5b9cbbb1b92f55412e676a38cbf0.tar.gz
dotty-141fb4b8c63e5b9cbbb1b92f55412e676a38cbf0.tar.bz2
dotty-141fb4b8c63e5b9cbbb1b92f55412e676a38cbf0.zip
Merge pull request #2043 from dotty-staging/tailrec-derivesFrom
Tailrec for derivesFrom/lookupRefined/classSymbol/classSymbols
Diffstat (limited to 'compiler/src/dotty/tools/dotc/transform/SymUtils.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/transform/SymUtils.scala6
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/src/dotty/tools/dotc/transform/SymUtils.scala b/compiler/src/dotty/tools/dotc/transform/SymUtils.scala
index 05305575e..105f54d3a 100644
--- a/compiler/src/dotty/tools/dotc/transform/SymUtils.scala
+++ b/compiler/src/dotty/tools/dotc/transform/SymUtils.scala
@@ -12,7 +12,9 @@ import StdNames._
import NameOps._
import Flags._
import Annotations._
+
import language.implicitConversions
+import scala.annotation.tailrec
object SymUtils {
implicit def decorateSymbol(sym: Symbol): SymUtils = new SymUtils(sym)
@@ -59,14 +61,14 @@ class SymUtils(val self: Symbol) extends AnyVal {
}
/** The closest enclosing method or class of this symbol */
- final def enclosingMethodOrClass(implicit ctx: Context): Symbol =
+ @tailrec final def enclosingMethodOrClass(implicit ctx: Context): Symbol =
if (self.is(Method, butNot = Label) || self.isClass) self
else if (self.exists) self.owner.enclosingMethodOrClass
else NoSymbol
/** Apply symbol/symbol substitution to this symbol */
def subst(from: List[Symbol], to: List[Symbol]): Symbol = {
- def loop(from: List[Symbol], to: List[Symbol]): Symbol =
+ @tailrec def loop(from: List[Symbol], to: List[Symbol]): Symbol =
if (from.isEmpty) self
else if (self eq from.head) to.head
else loop(from.tail, to.tail)