summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2013-01-05 02:11:47 +0300
committerEugene Burmako <xeno.by@gmail.com>2013-01-09 08:10:48 +0100
commit143cd7a307706a8884c9352e64addf6e9be0a181 (patch)
tree291ddfddd694a894158b35939b8bded093f61df2 /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parentfe6028476931b031e712c37d3e570125b1d034ae (diff)
downloadscala-143cd7a307706a8884c9352e64addf6e9be0a181.tar.gz
scala-143cd7a307706a8884c9352e64addf6e9be0a181.tar.bz2
scala-143cd7a307706a8884c9352e64addf6e9be0a181.zip
macroExpandAll is now triggered by typed
Previously delayed macro expansions (the sole purpose of macroExpandAll) were triggered by `typedArgs`. Probably I wanted to save CPU cycles on not checking whether we have pending macro expansions on every iteration of typecheck. However this optimization is uncalled for, because the check just entails reading a var, therefore benefits of the current approach are negliible, whereas the robustness hit is tangible. After delayed macro expansion mechanism became more robust, it exposed a bug, well-hidden before. If one first delays a macro and then finds out that the expandee is erroneous, subsequent `macroExpandAll` will crash, because it expects a macro runtime attachment to be present. Previously the erroneous code path never got triggered, because the macro expansion never commenced. Luckily the fix was easy.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index b0b1341a07..73d7f8928a 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -2892,7 +2892,6 @@ trait Typers extends Modes with Adaptations with Tags {
else BYVALmode
)
var tree = typedArg(args.head, mode, typedMode, adapted.head)
- if (hasPendingMacroExpansions) tree = macroExpandAll(this, tree)
// formals may be empty, so don't call tail
tree :: loop(args.tail, formals drop 1, adapted.tail)
}
@@ -5208,7 +5207,12 @@ trait Typers extends Modes with Adaptations with Tags {
}
tree1 modifyType (addAnnotations(tree1, _))
- val result = if (tree1.isEmpty) tree1 else adapt(tree1, mode, pt, tree)
+ val result =
+ if (tree1.isEmpty) tree1
+ else {
+ val result = adapt(tree1, mode, pt, tree)
+ if (hasPendingMacroExpansions) macroExpandAll(this, result) else result
+ }
if (!alreadyTyped) {
printTyping("adapted %s: %s to %s, %s".format(