summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-04-14 10:33:10 +0200
committerEugene Burmako <xeno.by@gmail.com>2012-04-14 11:33:56 +0200
commit0ba3d542cc236ab2dbed3dc551920ede94787a0c (patch)
tree9e7e6e0c26a8d2f8e5b62fbf2a609349acbd8855
parent3a2901da406f2478b5634b0636e56de9c4cd676d (diff)
downloadscala-0ba3d542cc236ab2dbed3dc551920ede94787a0c.tar.gz
scala-0ba3d542cc236ab2dbed3dc551920ede94787a0c.tar.bz2
scala-0ba3d542cc236ab2dbed3dc551920ede94787a0c.zip
restores some disabled macro tests, makes checkFeature synchronous when used for macros
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Macros.scala13
-rw-r--r--test/disabled/neg/macro-deprecate-dont-touch-backquotedidents.check10
-rw-r--r--test/disabled/neg/macro-deprecate-idents.check46
-rw-r--r--test/disabled/neg/macro-invalidshape-d.check4
-rw-r--r--test/disabled/neg/macro-keyword-bind.flags2
-rw-r--r--test/disabled/neg/macro-keyword-class1.flags2
-rw-r--r--test/disabled/neg/macro-keyword-class2.flags2
-rw-r--r--test/disabled/neg/macro-keyword-object1.flags2
-rw-r--r--test/disabled/neg/macro-keyword-object2.flags2
-rw-r--r--test/disabled/neg/macro-keyword-package1.flags2
-rw-r--r--test/disabled/neg/macro-keyword-package2.flags2
-rw-r--r--test/disabled/neg/macro-keyword-trait1.flags2
-rw-r--r--test/disabled/neg/macro-keyword-trait2.flags2
-rw-r--r--test/disabled/neg/macro-keyword-type.flags2
-rw-r--r--test/disabled/neg/macro-keyword-val.flags2
-rw-r--r--test/disabled/neg/macro-without-xmacros-a.check10
-rw-r--r--test/disabled/neg/macro-without-xmacros-b.check10
-rw-r--r--test/disabled/run/macro-reflective-mamd-normal-mi.check0
-rw-r--r--test/disabled/run/macro-reflective-mamd-normal-mi.flags0
-rw-r--r--test/files/neg/macro-deprecate-idents.check52
-rw-r--r--test/files/neg/macro-deprecate-idents.flags (renamed from test/disabled/neg/macro-deprecate-idents.flags)0
-rw-r--r--test/files/neg/macro-deprecate-idents.scala (renamed from test/disabled/neg/macro-deprecate-idents.scala)0
-rw-r--r--test/files/neg/macro-invalidshape-d.check8
-rw-r--r--test/files/neg/macro-invalidshape-d.flags (renamed from test/disabled/neg/macro-invalidshape-d.flags)0
-rw-r--r--test/files/neg/macro-invalidshape-d/Impls_1.scala (renamed from test/disabled/neg/macro-invalidshape-d/Impls_1.scala)0
-rw-r--r--test/files/neg/macro-invalidshape-d/Macros_Test_2.scala (renamed from test/disabled/neg/macro-invalidshape-d/Macros_Test_2.scala)0
-rw-r--r--test/files/neg/macro-without-xmacros-a.check17
-rw-r--r--test/files/neg/macro-without-xmacros-a/Impls_1.scala (renamed from test/disabled/neg/macro-without-xmacros-a/Impls_1.scala)6
-rw-r--r--test/files/neg/macro-without-xmacros-a/Macros_2.scala (renamed from test/disabled/neg/macro-without-xmacros-a/Macros_2.scala)0
-rw-r--r--test/files/neg/macro-without-xmacros-a/Test_3.scala (renamed from test/disabled/neg/macro-without-xmacros-a/Test_3.scala)0
-rw-r--r--test/files/neg/macro-without-xmacros-b.check17
-rw-r--r--test/files/neg/macro-without-xmacros-b/Impls_1.scala (renamed from test/disabled/neg/macro-without-xmacros-b/Impls_1.scala)6
-rw-r--r--test/files/neg/macro-without-xmacros-b/Macros_2.scala (renamed from test/disabled/neg/macro-without-xmacros-b/Macros_2.scala)0
-rw-r--r--test/files/neg/macro-without-xmacros-b/Test_3.scala (renamed from test/disabled/neg/macro-without-xmacros-b/Test_3.scala)0
-rw-r--r--test/files/pos/macro-deprecate-dont-touch-backquotedidents.flags (renamed from test/disabled/neg/macro-deprecate-dont-touch-backquotedidents.flags)0
-rw-r--r--test/files/pos/macro-deprecate-dont-touch-backquotedidents.scala (renamed from test/disabled/neg/macro-deprecate-dont-touch-backquotedidents.scala)12
-rw-r--r--test/files/run/macro-reflective-mamd-normal-mi.check1
-rw-r--r--test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala (renamed from test/disabled/run/macro-reflective-mamd-normal-mi/Impls_1.scala)0
-rw-r--r--test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala (renamed from test/disabled/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala)3
-rw-r--r--test/files/run/t2886.check10
-rw-r--r--test/files/run/t2886.scala9
42 files changed, 148 insertions, 110 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index b4e0ad6edf..4fb9362ccc 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -166,7 +166,7 @@ trait Implicits {
}
def isCyclicOrErroneous =
- try containsError(tpe)
+ try sym.hasFlag(LOCKED) || containsError(tpe)
catch { case _: CyclicReference => true }
var useCountArg: Int = 0
diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
index 988b821d1a..b7e0eaef2b 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
@@ -184,8 +184,21 @@ trait Macros { self: Analyzer =>
def typedMacroBody(typer: Typer, ddef: DefDef): Tree = {
import typer.context
if (macroDebug) println("typechecking macro def %s at %s".format(ddef.symbol, ddef.pos))
+
typer.checkFeature(ddef.pos, MacrosFeature)
+ // [Eugene to Martin] todo. copy/pasted this from checkFeature, because don't know a better way
+ // this is necessary to prevent macros from typechecking/expanding when they are not enabled
+ // `checkFeature` call alone is not enough, because it merely posts validation callback to unit.toCheck
+ def hasImport = inferImplicit(EmptyTree: Tree, MacrosFeature.tpe, true, false, typer.context) != SearchFailure
+ val nestedOwners = MacrosFeature.owner.ownerChain.takeWhile(_ != languageFeatureModule.moduleClass).reverse
+ val featureName = (nestedOwners map (_.name + ".")).mkString + MacrosFeature.name
+ def hasOption = settings.language.value contains featureName
+ if (!hasImport && !hasOption) {
+ ddef.symbol setFlag IS_ERROR
+ return EmptyTree
+ }
+
implicit class AugmentedString(s: String) {
def abbreviateCoreAliases: String = { // hack!
var result = s
diff --git a/test/disabled/neg/macro-deprecate-dont-touch-backquotedidents.check b/test/disabled/neg/macro-deprecate-dont-touch-backquotedidents.check
deleted file mode 100644
index 25df9a6a4a..0000000000
--- a/test/disabled/neg/macro-deprecate-dont-touch-backquotedidents.check
+++ /dev/null
@@ -1,10 +0,0 @@
-macro-deprecate-dont-touch-backquotedidents.scala:37: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
-package `macro` {
- ^
-macro-deprecate-dont-touch-backquotedidents.scala:38: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
- package `macro`.bar {
- ^
-macro-deprecate-dont-touch-backquotedidents.scala:43: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
- package `macro`.foo {
- ^
-three errors found
diff --git a/test/disabled/neg/macro-deprecate-idents.check b/test/disabled/neg/macro-deprecate-idents.check
deleted file mode 100644
index bd685fc7b9..0000000000
--- a/test/disabled/neg/macro-deprecate-idents.check
+++ /dev/null
@@ -1,46 +0,0 @@
-macro-deprecate-idents.scala:2: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
- val macro = ???
- ^
-macro-deprecate-idents.scala:6: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
- var macro = ???
- ^
-macro-deprecate-idents.scala:10: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
- type macro = Int
- ^
-macro-deprecate-idents.scala:14: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
- class macro
- ^
-macro-deprecate-idents.scala:18: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
- class macro
- ^
-macro-deprecate-idents.scala:22: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
- object macro
- ^
-macro-deprecate-idents.scala:26: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
- object macro
- ^
-macro-deprecate-idents.scala:30: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
- trait macro
- ^
-macro-deprecate-idents.scala:34: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
- trait macro
- ^
-macro-deprecate-idents.scala:37: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
-package macro {
- ^
-macro-deprecate-idents.scala:38: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
- package macro.bar {
- ^
-macro-deprecate-idents.scala:43: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
- package macro.foo {
- ^
-macro-deprecate-idents.scala:48: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
- val Some(macro) = Some(42)
- ^
-macro-deprecate-idents.scala:50: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
- case macro => println(macro)
- ^
-macro-deprecate-idents.scala:55: error: in future versions of Scala "macro" will be a keyword. consider using a different name.
- def macro = 2
- ^
-15 errors found
diff --git a/test/disabled/neg/macro-invalidshape-d.check b/test/disabled/neg/macro-invalidshape-d.check
deleted file mode 100644
index 031aa653ab..0000000000
--- a/test/disabled/neg/macro-invalidshape-d.check
+++ /dev/null
@@ -1,4 +0,0 @@
-Macros_Test_2.scala:2: error: illegal start of statement
- def foo(x: Any) = {2; macro Impls.foo}
- ^
-one error found
diff --git a/test/disabled/neg/macro-keyword-bind.flags b/test/disabled/neg/macro-keyword-bind.flags
index 7fea2ff901..cd66464f2f 100644
--- a/test/disabled/neg/macro-keyword-bind.flags
+++ b/test/disabled/neg/macro-keyword-bind.flags
@@ -1 +1 @@
--Xmacros \ No newline at end of file
+-language:experimental.macros \ No newline at end of file
diff --git a/test/disabled/neg/macro-keyword-class1.flags b/test/disabled/neg/macro-keyword-class1.flags
index 7fea2ff901..cd66464f2f 100644
--- a/test/disabled/neg/macro-keyword-class1.flags
+++ b/test/disabled/neg/macro-keyword-class1.flags
@@ -1 +1 @@
--Xmacros \ No newline at end of file
+-language:experimental.macros \ No newline at end of file
diff --git a/test/disabled/neg/macro-keyword-class2.flags b/test/disabled/neg/macro-keyword-class2.flags
index 7fea2ff901..cd66464f2f 100644
--- a/test/disabled/neg/macro-keyword-class2.flags
+++ b/test/disabled/neg/macro-keyword-class2.flags
@@ -1 +1 @@
--Xmacros \ No newline at end of file
+-language:experimental.macros \ No newline at end of file
diff --git a/test/disabled/neg/macro-keyword-object1.flags b/test/disabled/neg/macro-keyword-object1.flags
index 7fea2ff901..cd66464f2f 100644
--- a/test/disabled/neg/macro-keyword-object1.flags
+++ b/test/disabled/neg/macro-keyword-object1.flags
@@ -1 +1 @@
--Xmacros \ No newline at end of file
+-language:experimental.macros \ No newline at end of file
diff --git a/test/disabled/neg/macro-keyword-object2.flags b/test/disabled/neg/macro-keyword-object2.flags
index 7fea2ff901..cd66464f2f 100644
--- a/test/disabled/neg/macro-keyword-object2.flags
+++ b/test/disabled/neg/macro-keyword-object2.flags
@@ -1 +1 @@
--Xmacros \ No newline at end of file
+-language:experimental.macros \ No newline at end of file
diff --git a/test/disabled/neg/macro-keyword-package1.flags b/test/disabled/neg/macro-keyword-package1.flags
index 7fea2ff901..cd66464f2f 100644
--- a/test/disabled/neg/macro-keyword-package1.flags
+++ b/test/disabled/neg/macro-keyword-package1.flags
@@ -1 +1 @@
--Xmacros \ No newline at end of file
+-language:experimental.macros \ No newline at end of file
diff --git a/test/disabled/neg/macro-keyword-package2.flags b/test/disabled/neg/macro-keyword-package2.flags
index 7fea2ff901..cd66464f2f 100644
--- a/test/disabled/neg/macro-keyword-package2.flags
+++ b/test/disabled/neg/macro-keyword-package2.flags
@@ -1 +1 @@
--Xmacros \ No newline at end of file
+-language:experimental.macros \ No newline at end of file
diff --git a/test/disabled/neg/macro-keyword-trait1.flags b/test/disabled/neg/macro-keyword-trait1.flags
index 7fea2ff901..cd66464f2f 100644
--- a/test/disabled/neg/macro-keyword-trait1.flags
+++ b/test/disabled/neg/macro-keyword-trait1.flags
@@ -1 +1 @@
--Xmacros \ No newline at end of file
+-language:experimental.macros \ No newline at end of file
diff --git a/test/disabled/neg/macro-keyword-trait2.flags b/test/disabled/neg/macro-keyword-trait2.flags
index 7fea2ff901..cd66464f2f 100644
--- a/test/disabled/neg/macro-keyword-trait2.flags
+++ b/test/disabled/neg/macro-keyword-trait2.flags
@@ -1 +1 @@
--Xmacros \ No newline at end of file
+-language:experimental.macros \ No newline at end of file
diff --git a/test/disabled/neg/macro-keyword-type.flags b/test/disabled/neg/macro-keyword-type.flags
index 7fea2ff901..cd66464f2f 100644
--- a/test/disabled/neg/macro-keyword-type.flags
+++ b/test/disabled/neg/macro-keyword-type.flags
@@ -1 +1 @@
--Xmacros \ No newline at end of file
+-language:experimental.macros \ No newline at end of file
diff --git a/test/disabled/neg/macro-keyword-val.flags b/test/disabled/neg/macro-keyword-val.flags
index 7fea2ff901..cd66464f2f 100644
--- a/test/disabled/neg/macro-keyword-val.flags
+++ b/test/disabled/neg/macro-keyword-val.flags
@@ -1 +1 @@
--Xmacros \ No newline at end of file
+-language:experimental.macros \ No newline at end of file
diff --git a/test/disabled/neg/macro-without-xmacros-a.check b/test/disabled/neg/macro-without-xmacros-a.check
deleted file mode 100644
index a3ca081f04..0000000000
--- a/test/disabled/neg/macro-without-xmacros-a.check
+++ /dev/null
@@ -1,10 +0,0 @@
-Macros_2.scala:5: error: not found: value macro
- def foo(x: Int): Int = macro foo_impl
- ^
-Macros_2.scala:7: error: not found: value macro
- def bar(x: Int): Int = macro bar_impl
- ^
-Macros_2.scala:11: error: not found: value macro
- def quux(x: Int): Int = macro quux_impl
- ^
-three errors found
diff --git a/test/disabled/neg/macro-without-xmacros-b.check b/test/disabled/neg/macro-without-xmacros-b.check
deleted file mode 100644
index dce4a084c9..0000000000
--- a/test/disabled/neg/macro-without-xmacros-b.check
+++ /dev/null
@@ -1,10 +0,0 @@
-Macros_2.scala:3: error: ';' expected but '.' found.
- def foo(x: Int): Int = macro Impls.foo_impl
- ^
-Macros_2.scala:5: error: ';' expected but '.' found.
- def bar(x: Int): Int = macro Impls.bar_impl
- ^
-Macros_2.scala:9: error: ';' expected but '.' found.
- def quux(x: Int): Int = macro Impls.quux_impl
- ^
-three errors found
diff --git a/test/disabled/run/macro-reflective-mamd-normal-mi.check b/test/disabled/run/macro-reflective-mamd-normal-mi.check
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/disabled/run/macro-reflective-mamd-normal-mi.check
+++ /dev/null
diff --git a/test/disabled/run/macro-reflective-mamd-normal-mi.flags b/test/disabled/run/macro-reflective-mamd-normal-mi.flags
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/disabled/run/macro-reflective-mamd-normal-mi.flags
+++ /dev/null
diff --git a/test/files/neg/macro-deprecate-idents.check b/test/files/neg/macro-deprecate-idents.check
new file mode 100644
index 0000000000..f8a7e519df
--- /dev/null
+++ b/test/files/neg/macro-deprecate-idents.check
@@ -0,0 +1,52 @@
+macro-deprecate-idents.scala:2: error: macro is now a reserved word; usage as an identifier is deprecated
+ val macro = ???
+ ^
+macro-deprecate-idents.scala:6: error: macro is now a reserved word; usage as an identifier is deprecated
+ var macro = ???
+ ^
+macro-deprecate-idents.scala:10: error: macro is now a reserved word; usage as an identifier is deprecated
+ type macro = Int
+ ^
+macro-deprecate-idents.scala:14: error: macro is now a reserved word; usage as an identifier is deprecated
+ class macro
+ ^
+macro-deprecate-idents.scala:18: error: macro is now a reserved word; usage as an identifier is deprecated
+ class macro
+ ^
+macro-deprecate-idents.scala:22: error: macro is now a reserved word; usage as an identifier is deprecated
+ object macro
+ ^
+macro-deprecate-idents.scala:26: error: macro is now a reserved word; usage as an identifier is deprecated
+ object macro
+ ^
+macro-deprecate-idents.scala:30: error: macro is now a reserved word; usage as an identifier is deprecated
+ trait macro
+ ^
+macro-deprecate-idents.scala:34: error: macro is now a reserved word; usage as an identifier is deprecated
+ trait macro
+ ^
+macro-deprecate-idents.scala:37: error: macro is now a reserved word; usage as an identifier is deprecated
+package macro {
+ ^
+macro-deprecate-idents.scala:38: error: macro is now a reserved word; usage as an identifier is deprecated
+ package macro.bar {
+ ^
+macro-deprecate-idents.scala:43: error: macro is now a reserved word; usage as an identifier is deprecated
+ package macro.foo {
+ ^
+macro-deprecate-idents.scala:48: error: macro is now a reserved word; usage as an identifier is deprecated
+ val Some(macro) = Some(42)
+ ^
+macro-deprecate-idents.scala:49: error: macro is now a reserved word; usage as an identifier is deprecated
+ macro match {
+ ^
+macro-deprecate-idents.scala:50: error: macro is now a reserved word; usage as an identifier is deprecated
+ case macro => println(macro)
+ ^
+macro-deprecate-idents.scala:50: error: macro is now a reserved word; usage as an identifier is deprecated
+ case macro => println(macro)
+ ^
+macro-deprecate-idents.scala:55: error: macro is now a reserved word; usage as an identifier is deprecated
+ def macro = 2
+ ^
+17 errors found
diff --git a/test/disabled/neg/macro-deprecate-idents.flags b/test/files/neg/macro-deprecate-idents.flags
index e8fb65d50c..e8fb65d50c 100644
--- a/test/disabled/neg/macro-deprecate-idents.flags
+++ b/test/files/neg/macro-deprecate-idents.flags
diff --git a/test/disabled/neg/macro-deprecate-idents.scala b/test/files/neg/macro-deprecate-idents.scala
index 23c398e341..23c398e341 100644
--- a/test/disabled/neg/macro-deprecate-idents.scala
+++ b/test/files/neg/macro-deprecate-idents.scala
diff --git a/test/files/neg/macro-invalidshape-d.check b/test/files/neg/macro-invalidshape-d.check
new file mode 100644
index 0000000000..f0d77e2f2d
--- /dev/null
+++ b/test/files/neg/macro-invalidshape-d.check
@@ -0,0 +1,8 @@
+Macros_Test_2.scala:2: warning: macro is now a reserved word; usage as an identifier is deprecated
+ def foo(x: Any) = {2; macro Impls.foo}
+ ^
+Macros_Test_2.scala:2: error: ';' expected but '.' found.
+ def foo(x: Any) = {2; macro Impls.foo}
+ ^
+one warning found
+one error found
diff --git a/test/disabled/neg/macro-invalidshape-d.flags b/test/files/neg/macro-invalidshape-d.flags
index cd66464f2f..cd66464f2f 100644
--- a/test/disabled/neg/macro-invalidshape-d.flags
+++ b/test/files/neg/macro-invalidshape-d.flags
diff --git a/test/disabled/neg/macro-invalidshape-d/Impls_1.scala b/test/files/neg/macro-invalidshape-d/Impls_1.scala
index 7b1620d117..7b1620d117 100644
--- a/test/disabled/neg/macro-invalidshape-d/Impls_1.scala
+++ b/test/files/neg/macro-invalidshape-d/Impls_1.scala
diff --git a/test/disabled/neg/macro-invalidshape-d/Macros_Test_2.scala b/test/files/neg/macro-invalidshape-d/Macros_Test_2.scala
index bacd9a6e7c..bacd9a6e7c 100644
--- a/test/disabled/neg/macro-invalidshape-d/Macros_Test_2.scala
+++ b/test/files/neg/macro-invalidshape-d/Macros_Test_2.scala
diff --git a/test/files/neg/macro-without-xmacros-a.check b/test/files/neg/macro-without-xmacros-a.check
new file mode 100644
index 0000000000..fd2667dbb8
--- /dev/null
+++ b/test/files/neg/macro-without-xmacros-a.check
@@ -0,0 +1,17 @@
+Macros_2.scala:5: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
+This can be achieved by adding the import clause 'import language.experimental.macros'
+or by setting the compiler option -language:experimental.macros.
+See the Scala docs for value scala.language.experimental.macros for a discussion
+why the feature needs to be explicitly enabled.
+ def foo(x: Int): Int = macro foo_impl
+ ^
+Macros_2.scala:7: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
+ def bar(x: Int): Int = macro bar_impl
+ ^
+Macros_2.scala:11: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
+ def quux(x: Int): Int = macro quux_impl
+ ^
+three errors found
diff --git a/test/disabled/neg/macro-without-xmacros-a/Impls_1.scala b/test/files/neg/macro-without-xmacros-a/Impls_1.scala
index 2493c81c95..01daf12b1a 100644
--- a/test/disabled/neg/macro-without-xmacros-a/Impls_1.scala
+++ b/test/files/neg/macro-without-xmacros-a/Impls_1.scala
@@ -1,17 +1,17 @@
import scala.reflect.makro.{Context => Ctx}
object Impls {
- def foo_impl(c: Ctx)(x: c.Expr[Int]): c.mirror.Tree = {
+ def foo_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
import c.mirror._
Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1))))
}
- def bar_impl(c: Ctx)(x: c.Expr[Int]): c.mirror.Tree = {
+ def bar_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
import c.mirror._
Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2))))
}
- def quux_impl(c: Ctx)(x: c.Expr[Int]): c.mirror.Tree = {
+ def quux_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
import c.mirror._
Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3))))
}
diff --git a/test/disabled/neg/macro-without-xmacros-a/Macros_2.scala b/test/files/neg/macro-without-xmacros-a/Macros_2.scala
index 62f9dcf505..62f9dcf505 100644
--- a/test/disabled/neg/macro-without-xmacros-a/Macros_2.scala
+++ b/test/files/neg/macro-without-xmacros-a/Macros_2.scala
diff --git a/test/disabled/neg/macro-without-xmacros-a/Test_3.scala b/test/files/neg/macro-without-xmacros-a/Test_3.scala
index e9a10e20c9..e9a10e20c9 100644
--- a/test/disabled/neg/macro-without-xmacros-a/Test_3.scala
+++ b/test/files/neg/macro-without-xmacros-a/Test_3.scala
diff --git a/test/files/neg/macro-without-xmacros-b.check b/test/files/neg/macro-without-xmacros-b.check
new file mode 100644
index 0000000000..2d675b8319
--- /dev/null
+++ b/test/files/neg/macro-without-xmacros-b.check
@@ -0,0 +1,17 @@
+Macros_2.scala:3: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
+This can be achieved by adding the import clause 'import language.experimental.macros'
+or by setting the compiler option -language:experimental.macros.
+See the Scala docs for value scala.language.experimental.macros for a discussion
+why the feature needs to be explicitly enabled.
+ def foo(x: Int): Int = macro Impls.foo_impl
+ ^
+Macros_2.scala:5: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
+ def bar(x: Int): Int = macro Impls.bar_impl
+ ^
+Macros_2.scala:9: error: macro definition needs to be enabled
+by making the implicit value language.experimental.macros visible.
+ def quux(x: Int): Int = macro Impls.quux_impl
+ ^
+three errors found
diff --git a/test/disabled/neg/macro-without-xmacros-b/Impls_1.scala b/test/files/neg/macro-without-xmacros-b/Impls_1.scala
index 2493c81c95..01daf12b1a 100644
--- a/test/disabled/neg/macro-without-xmacros-b/Impls_1.scala
+++ b/test/files/neg/macro-without-xmacros-b/Impls_1.scala
@@ -1,17 +1,17 @@
import scala.reflect.makro.{Context => Ctx}
object Impls {
- def foo_impl(c: Ctx)(x: c.Expr[Int]): c.mirror.Tree = {
+ def foo_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
import c.mirror._
Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1))))
}
- def bar_impl(c: Ctx)(x: c.Expr[Int]): c.mirror.Tree = {
+ def bar_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
import c.mirror._
Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2))))
}
- def quux_impl(c: Ctx)(x: c.Expr[Int]): c.mirror.Tree = {
+ def quux_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = {
import c.mirror._
Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3))))
}
diff --git a/test/disabled/neg/macro-without-xmacros-b/Macros_2.scala b/test/files/neg/macro-without-xmacros-b/Macros_2.scala
index de7080c7e8..de7080c7e8 100644
--- a/test/disabled/neg/macro-without-xmacros-b/Macros_2.scala
+++ b/test/files/neg/macro-without-xmacros-b/Macros_2.scala
diff --git a/test/disabled/neg/macro-without-xmacros-b/Test_3.scala b/test/files/neg/macro-without-xmacros-b/Test_3.scala
index e9a10e20c9..e9a10e20c9 100644
--- a/test/disabled/neg/macro-without-xmacros-b/Test_3.scala
+++ b/test/files/neg/macro-without-xmacros-b/Test_3.scala
diff --git a/test/disabled/neg/macro-deprecate-dont-touch-backquotedidents.flags b/test/files/pos/macro-deprecate-dont-touch-backquotedidents.flags
index e8fb65d50c..e8fb65d50c 100644
--- a/test/disabled/neg/macro-deprecate-dont-touch-backquotedidents.flags
+++ b/test/files/pos/macro-deprecate-dont-touch-backquotedidents.flags
diff --git a/test/disabled/neg/macro-deprecate-dont-touch-backquotedidents.scala b/test/files/pos/macro-deprecate-dont-touch-backquotedidents.scala
index dee2f1de3b..69a7333011 100644
--- a/test/disabled/neg/macro-deprecate-dont-touch-backquotedidents.scala
+++ b/test/files/pos/macro-deprecate-dont-touch-backquotedidents.scala
@@ -44,12 +44,12 @@ package foo {
}
}
-object Test12 {
- val Some(`macro`) = Some(42)
- `macro` match {
- case `macro` => println(`macro`)
- }
-}
+//object Test12 {
+// val Some(`macro`) = Some(42)
+// `macro` match {
+// case `macro` => println(`macro`)
+// }
+//}
object Test13 {
def `macro` = 2
diff --git a/test/files/run/macro-reflective-mamd-normal-mi.check b/test/files/run/macro-reflective-mamd-normal-mi.check
new file mode 100644
index 0000000000..ac4213d6e9
--- /dev/null
+++ b/test/files/run/macro-reflective-mamd-normal-mi.check
@@ -0,0 +1 @@
+43 \ No newline at end of file
diff --git a/test/disabled/run/macro-reflective-mamd-normal-mi/Impls_1.scala b/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala
index dc7d42d23e..dc7d42d23e 100644
--- a/test/disabled/run/macro-reflective-mamd-normal-mi/Impls_1.scala
+++ b/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala
diff --git a/test/disabled/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala
index 7cbe425fc8..cf34f1685d 100644
--- a/test/disabled/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala
+++ b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala
@@ -12,5 +12,6 @@ object Test extends App {
val module = ModuleDef(NoMods, newTermName("Macros"), Template(Nil, emptyValDef, List(modulector, macrodef)))
val macroapp = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42))))
val tree = Block(macrodef, module, macroapp)
- println(tree.eval)
+ val toolbox = mkToolBox(options = "-language:experimental.macros")
+ println(toolbox.runExpr(tree))
}
diff --git a/test/files/run/t2886.check b/test/files/run/t2886.check
index 5fe1e73a45..8d97a82799 100644
--- a/test/files/run/t2886.check
+++ b/test/files/run/t2886.check
@@ -1,5 +1,5 @@
-((x: scala.Predef.String) => {
- val x$1 = x;
- val x$2 = x;
- Test.test(x$2, x$1)
-})
+((x: String) => {
+ val x$1 = x;
+ val x$2 = x;
+ Test.this.test(x$2, x$1)
+})
diff --git a/test/files/run/t2886.scala b/test/files/run/t2886.scala
new file mode 100644
index 0000000000..e0835a0a44
--- /dev/null
+++ b/test/files/run/t2886.scala
@@ -0,0 +1,9 @@
+import scala.reflect.mirror._
+
+object Test {
+ def test(name: String, address: String) = null
+ def main(args: Array[String]) = {
+ val tree = reify((x:String) => test(address=x,name=x)).tree
+ println(tree)
+ }
+}