diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-11-05 10:53:15 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-01-31 22:12:37 +0100 |
commit | 67f7df27a8f4f97929140904eec237541d2b65ab (patch) | |
tree | 4f29c6bee0864fb0fd0c1e908bd971c1879c0bdf /src/compiler | |
parent | eb2627c4d282b5e4727e7e67fc7656409119cc96 (diff) | |
download | scala-67f7df27a8f4f97929140904eec237541d2b65ab.tar.gz scala-67f7df27a8f4f97929140904eec237541d2b65ab.tar.bz2 scala-67f7df27a8f4f97929140904eec237541d2b65ab.zip |
Optimize tailcall elimination
From the "if a tree falls" department: don't bother create a finely
distinguished error messages about why the transform is inapplicable
if the current context doesn't demand it.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/TailCalls.scala | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/TailCalls.scala b/src/compiler/scala/tools/nsc/transform/TailCalls.scala index cf38390e37..05fa65eb9c 100644 --- a/src/compiler/scala/tools/nsc/transform/TailCalls.scala +++ b/src/compiler/scala/tools/nsc/transform/TailCalls.scala @@ -237,7 +237,8 @@ abstract class TailCalls extends Transform { if (!ctx.isEligible) fail("it is neither private nor final so can be overridden") else if (!isRecursiveCall) { - if (receiverIsSuper) failHere("it contains a recursive call targeting a supertype") + if (ctx.isMandatory && receiverIsSuper) // OPT expensive check, avoid unless we will actually report the error + failHere("it contains a recursive call targeting a supertype") else failHere(defaultReason) } else if (!matchesTypeArgs) failHere("it is called recursively with different type arguments") |