summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/ToolBoxes.scala3
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Macros.scala12
-rw-r--r--test/files/run/inner-parse/S_3.scala2
-rw-r--r--test/files/run/t5713.check1
-rw-r--r--test/files/run/t5713.flags1
-rw-r--r--test/files/run/t5713/Impls_Macros_1.scala27
-rw-r--r--test/files/run/t5713/Test_2.scala5
7 files changed, 43 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/ToolBoxes.scala b/src/compiler/scala/tools/nsc/ToolBoxes.scala
index 5b2b5ff5e9..8bf977090b 100644
--- a/src/compiler/scala/tools/nsc/ToolBoxes.scala
+++ b/src/compiler/scala/tools/nsc/ToolBoxes.scala
@@ -39,7 +39,8 @@ trait ToolBoxes { self: Global =>
def runExpr(tree0: Tree, freeTypes: Map[FreeType, Type] = Map[FreeType, Type]()): Any = {
var tree = substituteFreeTypes(tree0, freeTypes)
// need to reset the tree, otherwise toolbox will refuse to work with it
- tree = resetAllAttrs(tree0.duplicate)
+ // upd. this has to be done by the user himself, otherwise we run into troubles. see SI-5713
+// tree = resetAllAttrs(tree0.duplicate)
val imported = importer.importTree(tree)
val toolBox = libraryClasspathMirror.mkToolBox(frontEnd.asInstanceOf[libraryClasspathMirror.FrontEnd], options)
try toolBox.runExpr(imported)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
index 1b8a43bf27..353514c397 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
@@ -1010,7 +1010,7 @@ trait Macros extends Traces {
private def Failure(expandee: Tree) = Other(expandee)
private def fail(typer: Typer, expandee: Tree, msg: String = null) = {
def msgForLog = if (msg != null && (msg contains "exception during macro expansion")) msg.split(EOL).drop(1).headOption.getOrElse("?") else msg
- macroLogVerbose("macro expansion has failed: %s".format(msgForLog))
+ macroLogLite("macro expansion has failed: %s".format(msgForLog))
val pos = if (expandee.pos != NoPosition) expandee.pos else enclosingMacroPosition
if (msg != null) typer.context.error(pos, msg)
typer.infer.setError(expandee)
@@ -1079,7 +1079,7 @@ trait Macros extends Traces {
else expanded match {
case expanded: Expr[_] =>
macroLogVerbose("original:")
- macroLogVerbose("" + expanded.tree + "\n" + showRaw(expanded.tree))
+ macroLogLite("" + expanded.tree + "\n" + showRaw(expanded.tree))
freeTerms(expanded.tree) foreach issueFreeError
freeTypes(expanded.tree) foreach issueFreeError
@@ -1105,11 +1105,11 @@ trait Macros extends Traces {
else Skip(macroExpandAll(typer, expandee))
}
else {
- macroLogVerbose("typechecking macro expansion %s at %s".format(expandee, expandee.pos))
+ macroLogLite("typechecking macro expansion %s at %s".format(expandee, expandee.pos))
macroArgs(typer, expandee).fold(failExpansion(): MacroExpansionResult) {
case args @ ((context: MacroContext) :: _) =>
if (nowDelayed) {
- macroLogVerbose("macro expansion is delayed: %s".format(expandee))
+ macroLogLite("macro expansion is delayed: %s".format(expandee))
delayed += expandee -> undetparams
// need to save typer context for `macroExpandAll`
// need to save macro context to preserve enclosures
@@ -1176,7 +1176,7 @@ trait Macros extends Traces {
}
fallBackToOverridden(expandee) match {
case Some(tree1) =>
- macroTraceVerbose("falling back to: ")(tree1)
+ macroTraceLite("falling back to: ")(tree1)
currentRun.macroExpansionFailed = true
Fallback(tree1)
case None =>
@@ -1192,7 +1192,7 @@ trait Macros extends Traces {
macroLogVerbose("macro expansion has failed: %s".format(realex.msg))
fail(typer, expandee) // error has been reported by abort
case err: TypeError =>
- macroLogVerbose("macro expansion has failed: %s at %s".format(err.msg, err.pos))
+ macroLogLite("macro expansion has failed: %s at %s".format(err.msg, err.pos))
throw err // error should be propagated, don't report
case _ =>
val message = {
diff --git a/test/files/run/inner-parse/S_3.scala b/test/files/run/inner-parse/S_3.scala
index 296a651460..12ea325a83 100644
--- a/test/files/run/inner-parse/S_3.scala
+++ b/test/files/run/inner-parse/S_3.scala
@@ -5,7 +5,7 @@ object Test {
val cwd = sys.props("partest.output")
for ((f, info) <- JvmClassInfo.classInfoList(cwd)) {
- println("file " + f.stripPrefix(cwd + "/"))
+ println("file " + f.stripPrefix(cwd).substring(1))
println(info)
}
}
diff --git a/test/files/run/t5713.check b/test/files/run/t5713.check
new file mode 100644
index 0000000000..d3e9348123
--- /dev/null
+++ b/test/files/run/t5713.check
@@ -0,0 +1 @@
+err
diff --git a/test/files/run/t5713.flags b/test/files/run/t5713.flags
new file mode 100644
index 0000000000..cd66464f2f
--- /dev/null
+++ b/test/files/run/t5713.flags
@@ -0,0 +1 @@
+-language:experimental.macros \ No newline at end of file
diff --git a/test/files/run/t5713/Impls_Macros_1.scala b/test/files/run/t5713/Impls_Macros_1.scala
new file mode 100644
index 0000000000..b499bc7e4e
--- /dev/null
+++ b/test/files/run/t5713/Impls_Macros_1.scala
@@ -0,0 +1,27 @@
+package m
+
+import language.experimental.macros
+import scala.reflect.makro.Context
+
+object Level extends Enumeration {
+ val Error = Value(5)
+}
+
+object Logger {
+ def error(message: String): Unit = macro LoggerMacros.error
+}
+
+private object LoggerMacros {
+
+ type LoggerContext = Context { type PrefixType = Logger.type }
+
+ def error(c: LoggerContext)(message: c.Expr[String]): c.Expr[Unit] =
+ log(c)(c.reify(Level.Error), message)
+
+ private def log(c: LoggerContext)(level: c.Expr[Level.Value], message: c.Expr[String]): c.Expr[Unit] =
+ if (level.eval.id < 4) // TODO Remove hack!
+ c.reify(())
+ else {
+ c.reify(println(message.eval))
+ }
+} \ No newline at end of file
diff --git a/test/files/run/t5713/Test_2.scala b/test/files/run/t5713/Test_2.scala
new file mode 100644
index 0000000000..24f9e79b11
--- /dev/null
+++ b/test/files/run/t5713/Test_2.scala
@@ -0,0 +1,5 @@
+import m._
+
+object Test extends App {
+ Logger.error("err")
+} \ No newline at end of file