summaryrefslogtreecommitdiff
path: root/src/compiler/scala/reflect/macros/contexts
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2013-12-19 23:01:46 +0100
committerEugene Burmako <xeno.by@gmail.com>2013-12-19 23:21:36 +0100
commit187d73ed1b69118b8062d9cb7ddf85e79b469309 (patch)
tree560c1de9f0bdba65aaf3b75b4cbf3c7ed8e2c2a1 /src/compiler/scala/reflect/macros/contexts
parentb275c38c9491a6f7a47be40cb52e2935ca0e2d69 (diff)
downloadscala-187d73ed1b69118b8062d9cb7ddf85e79b469309.tar.gz
scala-187d73ed1b69118b8062d9cb7ddf85e79b469309.tar.bz2
scala-187d73ed1b69118b8062d9cb7ddf85e79b469309.zip
duplicates arguments to macro typer APIs
This commit continues the tendency set by the parent commit to duplicate as much as possible in order to avoid potential confusion that users might run into when compiler internals start leaking. Here we plumb another way that by-reference sharing of trees might bite unsuspecting macro writers. Previously we have duplicated macro expansions, macro arguments, c.macroApplication, and now it’s arguments to typeCheck and resetAttrs. There is still an unlikely situation when someone gets to c.enclosingXXX and then starts typechecking around, but that’s left for future work, as it’s yet unclear what to do with c.enclosingXXX APIs.
Diffstat (limited to 'src/compiler/scala/reflect/macros/contexts')
-rw-r--r--src/compiler/scala/reflect/macros/contexts/Typers.scala6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/compiler/scala/reflect/macros/contexts/Typers.scala b/src/compiler/scala/reflect/macros/contexts/Typers.scala
index 4a1122b913..4fa7603305 100644
--- a/src/compiler/scala/reflect/macros/contexts/Typers.scala
+++ b/src/compiler/scala/reflect/macros/contexts/Typers.scala
@@ -24,7 +24,7 @@ trait Typers {
// typechecking uses silent anyways (e.g. in typedSelect), so you'll only waste your time
// I'd advise fixing the root cause: finding why the context is not set to report errors
// (also see reflect.runtime.ToolBoxes.typeCheckExpr for a workaround that might work for you)
- wrapper(callsiteTyper.silent(_.typed(tree, pt), reportAmbiguousErrors = false) match {
+ wrapper(callsiteTyper.silent(_.typed(universe.duplicateAndKeepPositions(tree), pt), reportAmbiguousErrors = false) match {
case universe.analyzer.SilentResultValue(result) =>
macroLogVerbose(result)
result
@@ -46,7 +46,7 @@ trait Typers {
universe.analyzer.inferImplicit(tree, viewTpe, true, callsiteTyper.context, silent, withMacrosDisabled, pos, (pos, msg) => throw TypecheckException(pos, msg))
}
- def resetAllAttrs(tree: Tree): Tree = universe.resetAllAttrs(tree)
+ def resetAllAttrs(tree: Tree): Tree = universe.resetAllAttrs(universe.duplicateAndKeepPositions(tree))
- def resetLocalAttrs(tree: Tree): Tree = universe.resetLocalAttrs(tree)
+ def resetLocalAttrs(tree: Tree): Tree = universe.resetLocalAttrs(universe.duplicateAndKeepPositions(tree))
}