Permalink
Browse files

deprecates macro def return type inference

With the new focus on quasiquotes in macro implementations, we now have
to change the way how inference of macro def return types works.

Previously, if the return type of a macro def wasn’t specified, we looked into
the signature of its macro impl, took its return type (which could only
be c.Expr[T]) and then assigned T to be the return type of the macro def.

We also had a convenient special case which inferred Any in case when
the body of the macro impl wasn’t an expr. That avoided reporting spurious
errors if the macro impl had its body typed incorrectly (because in that
case we would report a def/impl signature mismatch anyway) and also provided
a convenience by letting macro impls end with `???`.

However now we also allow macro impls to return c.Tree, which means that
we are no longer able to do any meaningful type inference, because c.Tree
could correspond to tree of any type.

Unfortunately, when coupled with the type inference special case described
above, this means that the users who migrate from exprs to quasiquotes
are going to face an unpleasant surprise. If they haven’t provided
explicit return types for their macro defs, those types are going to be
silently inferred as `Any`!

This commit plugs this loophole by prohibiting type inference from
non-expr return types of macro impls (not counting Nothing). Moreover,
it also deprecates c.Expr[T] => T inference in order to avoid confusion
when switching between exprs and quasiquotes.
  • Loading branch information...
1 parent 75cc6cf commit 87979ad96f3a07354be4c15cdf35f71d1d4739cb @xeno-by xeno-by committed Dec 8, 2013
Showing with 245 additions and 235 deletions.
  1. +1 −1 src/compiler/scala/reflect/macros/compiler/Validators.scala
  2. +6 −2 src/compiler/scala/reflect/macros/util/Helpers.scala
  3. +17 −1 src/compiler/scala/tools/nsc/typechecker/Typers.scala
  4. +1 −1 test/files/neg/macro-blackbox-extractor/Macros_1.scala
  5. +1 −1 test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala
  6. +1 −1 test/files/neg/macro-bundle-object.check
  7. +21 −1 test/files/neg/macro-invalidret.check
  8. +3 −1 test/files/neg/macro-invalidret.flags
  9. +3 −0 test/files/neg/macro-invalidret/Impls_1.scala
  10. +8 −0 test/files/neg/macro-invalidret/Macros_Test_2.scala
  11. +1 −1 test/files/neg/macro-invalidsig-params-badtype.check
  12. +15 −15 test/files/neg/macro-invalidsig.check
  13. +3 −3 test/files/neg/macro-invalidsig/Macros_Test_2.scala
  14. +1 −1 test/files/neg/macro-invalidusage-badargs/Macros_Test_2.scala
  15. +1 −1 test/files/neg/macro-invalidusage-badbounds/Macros_Test_2.scala
  16. +5 −5 test/files/neg/macro-invalidusage-badtargs.check
  17. +7 −5 test/files/neg/macro-invalidusage-badtargs/Macros_Test_2.scala
  18. +1 −1 test/files/neg/macro-invalidusage-methodvaluesyntax/Macros_Test_2.scala
  19. +1 −1 test/files/neg/macro-override-macro-overrides-abstract-method-a.check
  20. +1 −1 test/files/neg/macro-override-macro-overrides-abstract-method-a/Impls_Macros_1.scala
  21. +1 −1 test/files/neg/macro-override-method-overrides-macro.check
  22. +7 −7 test/files/neg/macro-override-method-overrides-macro/Macros_Test_2.scala
  23. +3 −3 test/files/neg/macro-quasiquotes.check
  24. +3 −3 test/files/neg/macro-quasiquotes/Macros_1.scala
  25. +1 −1 test/files/neg/t5753/Impls_Macros_1.scala
  26. +1 −1 test/files/neg/t5753/Test_2.scala
  27. +1 −1 test/files/neg/t5903a/Macros_1.scala
  28. +1 −1 test/files/neg/t5903b/Macros_1.scala
  29. +1 −1 test/files/neg/t5903c/Macros_1.scala
  30. +1 −1 test/files/neg/t5903d/Macros_1.scala
  31. +1 −1 test/files/neg/t5903e/Macros_1.scala
  32. +1 −1 test/files/neg/t7519-b.check
  33. +2 −0 test/files/neg/t7519-b/Use_2.scala
  34. +1 −1 test/files/pos/t8001/Macros_1.scala
  35. +1 −1 test/files/run/macro-bodyexpandstoimpl/Impls_1.scala
  36. +1 −1 test/files/run/macro-bodyexpandstoimpl/Macros_Test_2.scala
  37. +2 −2 test/files/run/macro-bundle-repl.check
  38. +2 −2 test/files/run/macro-bundle-repl.scala
  39. +0 −8 test/files/run/macro-def-infer-return-type.check
  40. +0 −1 test/files/run/macro-def-infer-return-type.flags
  41. +0 −14 test/files/run/macro-def-infer-return-type/Impls_1.scala
  42. +0 −24 test/files/run/macro-def-infer-return-type/Macros_Test_2.scala
  43. +25 −23 test/files/run/macro-def-path-dependent/Test_1.scala
  44. +1 −1 test/files/run/macro-def-path-dependent/Test_2.scala
  45. +1 −1 test/files/run/macro-def-path-dependent/Test_4.scala
  46. +1 −1 test/files/run/macro-def-path-dependent/Test_6.scala
  47. +1 −1 test/files/run/macro-expand-implicit-macro-has-implicit/Macros_Test_2.scala
  48. +1 −1 test/files/run/macro-expand-implicit-macro-is-val/Macros_Test_2.scala
  49. +1 −1 test/files/run/macro-expand-multiple-arglists/Macros_Test_2.scala
  50. +4 −4 test/files/run/macro-expand-nullary-generic/Macros_Test_2.scala
  51. +4 −4 test/files/run/macro-expand-nullary-nongeneric/Macros_Test_2.scala
  52. +6 −6 test/files/run/macro-expand-overload/Macros_Test_2.scala
  53. +7 −7 test/files/run/macro-expand-override/Macros_Test_2.scala
  54. +2 −2 test/files/run/macro-expand-recursive/Macros_Test_2.scala
  55. +2 −2 test/files/run/macro-expand-tparams-bounds/Macros_Test_2.scala
  56. +1 −1 test/files/run/macro-expand-tparams-explicit/Macros_Test_2.scala
  57. +1 −1 test/files/run/macro-expand-tparams-implicit/Macros_Test_2.scala
  58. +4 −4 test/files/run/macro-expand-tparams-prefix/Macros_Test_2.scala
  59. +1 −1 test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala
  60. +1 −1 test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Macros_Test_2.scala
  61. +1 −1 test/files/run/macro-expand-varargs-explicit-over-varargs/Macros_Test_2.scala
  62. +1 −1 test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Macros_Test_2.scala
  63. +1 −1 test/files/run/macro-expand-varargs-implicit-over-varargs/Macros_Test_2.scala
  64. +1 −1 test/files/run/macro-impl-tparam-only-in-impl/Macros_Test_2.scala
  65. +1 −1 test/files/run/macro-impl-tparam-typetag-is-optional/Macros_Test_2.scala
  66. +3 −3 test/files/run/macro-quasiquotes/Macros_1.scala
  67. +0 −1 test/files/run/macro-reflective-mamd-normal-mi.check
  68. +2 −2 test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala
  69. +1 −1 test/files/run/macro-reify-ref-to-packageless/Test_2.scala
  70. +2 −2 test/files/run/macro-repl-dontexpand.check
  71. +1 −1 test/files/run/macro-system-properties.check
  72. +1 −1 test/files/run/macro-system-properties.scala
  73. +1 −1 test/files/run/macro-term-declared-in-anonymous/Macros_Test_2.scala
  74. +1 −1 test/files/run/macro-term-declared-in-block/Macros_Test_2.scala
  75. +1 −1 test/files/run/macro-term-declared-in-class-class/Macros_Test_2.scala
  76. +1 −1 test/files/run/macro-term-declared-in-class-object/Macros_Test_2.scala
  77. +1 −1 test/files/run/macro-term-declared-in-class/Macros_Test_2.scala
  78. +1 −1 test/files/run/macro-term-declared-in-default-param/Macros_Test_2.scala
  79. +1 −1 test/files/run/macro-term-declared-in-method/Macros_Test_2.scala
  80. +1 −1 test/files/run/macro-term-declared-in-object-class/Macros_Test_2.scala
  81. +1 −1 test/files/run/macro-term-declared-in-object-object/Macros_Test_2.scala
  82. +1 −1 test/files/run/macro-term-declared-in-object/Macros_Test_2.scala
  83. +1 −1 test/files/run/macro-term-declared-in-package-object/Macros_Test_2.scala
  84. +1 −2 test/files/run/macro-term-declared-in-refinement/Macros_Test_2.scala
  85. +1 −1 test/files/run/macro-term-declared-in-trait/Macros_Test_2.scala
  86. +2 −2 test/files/run/macro-vampire-false-warning/Macros_1.scala
  87. +1 −1 test/files/run/macro-whitebox-extractor/Macros_1.scala
  88. +1 −1 test/files/run/macro-whitebox-structural/Impls_Macros_1.scala
  89. +3 −3 test/files/run/repl-term-macros.check
  90. +3 −3 test/files/run/repl-term-macros.scala
  91. +1 −1 test/files/run/t5894.scala
  92. +1 −1 test/files/run/t5903a/Macros_1.scala
  93. +1 −1 test/files/run/t5903b/Macros_1.scala
  94. +1 −1 test/files/run/t5903c/Macros_1.scala
  95. +1 −1 test/files/run/t5903d/Macros_1.scala
  96. +1 −1 test/files/run/t5940.scala
  97. +1 −1 test/files/run/t6381.check
  98. +1 −1 test/files/run/t6381.scala
  99. +1 −1 test/files/run/t7617b/Test_2.scala
  100. +1 −1 test/files/run/t7871/Macros_1.scala
  101. +1 −1 test/files/run/toolbox_current_run_compiles.scala
  102. +3 −3 test/scaladoc/run/SI-6812.scala
View
2 src/compiler/scala/reflect/macros/compiler/Validators.scala
@@ -155,7 +155,7 @@ trait Validators {
else mmap(macroDdef.vparamss)(param)
val macroDefRet =
if (!macroDdef.tpt.isEmpty) typer.typedType(macroDdef.tpt).tpe
- else computeMacroDefTypeFromMacroImplRef(macroDdef, macroImplRef)
+ else computeMacroDefTypeFromMacroImplRef(macroDdef, macroImplRef) orElse AnyTpe
val implReturnType = sigma(increaseMetalevel(ctxPrefix, macroDefRet))
object SigmaTypeMap extends TypeMap {
View
8 src/compiler/scala/reflect/macros/util/Helpers.scala
@@ -77,7 +77,8 @@ trait Helpers {
/** Decreases metalevel of the type, i.e. transforms:
* * c.Expr[T] to T
- * * Anything else to Any
+ * * Nothing to Nothing
+ * * Anything else to NoType
*
* @see Metalevels.scala for more information and examples about metalevels
*/
@@ -86,7 +87,10 @@ trait Helpers {
import runDefinitions._
transparentShallowTransform(RepeatedParamClass, tp) {
case ExprClassOf(runtimeType) => runtimeType
- case _ => AnyTpe // so that macro impls with rhs = ??? don't screw up our inference
+ // special-casing Nothing here is a useful convention
+ // that enables no-hassle prototyping with `macro ???` and `macro { ...; ??? }`
+ case nothing if nothing =:= NothingTpe => NothingTpe
+ case _ => NoType
}
}
}
View
18 src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -5517,7 +5517,23 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
val isMacroBodyOkay = !tree.symbol.isErroneous && !(tree1 exists (_.isErroneous)) && tree1 != EmptyTree
val shouldInheritMacroImplReturnType = ddef.tpt.isEmpty
- if (isMacroBodyOkay && shouldInheritMacroImplReturnType) computeMacroDefTypeFromMacroImplRef(ddef, tree1) else AnyTpe
+ if (isMacroBodyOkay && shouldInheritMacroImplReturnType) {
+ val commonMessage = "macro defs must have explicitly specified return types"
+ def reportFailure() = {
+ ddef.symbol.setFlag(IS_ERROR)
+ unit.error(ddef.pos, commonMessage)
+ }
+ def reportWarning(inferredType: Type) = {
+ val explanation = s"inference of $inferredType from macro impl's c.Expr[$inferredType] is deprecated and is going to stop working in 2.12"
+ unit.deprecationWarning(ddef.pos, s"$commonMessage ($explanation)")
+ }
+ computeMacroDefTypeFromMacroImplRef(ddef, tree1) match {
+ case ErrorType => ErrorType
+ case NothingTpe => NothingTpe
+ case NoType => reportFailure(); AnyTpe
+ case tpe => reportWarning(tpe); tpe
+ }
+ } else AnyTpe
}
def transformedOr(tree: Tree, op: => Tree): Tree = transformed remove tree match {
View
2 test/files/neg/macro-blackbox-extractor/Macros_1.scala
@@ -2,7 +2,7 @@ import scala.reflect.macros.BlackboxContext
import language.experimental.macros
object Extractor {
- def unapply(x: Int) = macro Macros.unapplyImpl
+ def unapply(x: Int): Any = macro Macros.unapplyImpl
}
object Macros {
View
2 test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala
@@ -11,5 +11,5 @@ object Macros {
"""
}
- def foo = macro impl
+ def foo: Any = macro impl
}
View
2 test/files/neg/macro-bundle-object.check
@@ -1,5 +1,5 @@
macro-bundle-object.scala:10: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any]
+ required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing]
or : (c: scala.reflect.macros.BlackboxContext): c.Tree
found : : Nothing
number of parameter sections differ
View
22 test/files/neg/macro-invalidret.check
@@ -12,4 +12,24 @@ Macros_Test_2.scala:3: error: macro implementation has incompatible shape:
type mismatch for return type: reflect.runtime.universe.Literal does not conform to c.Expr[Any]
def foo2 = macro Impls.foo2
^
-two errors found
+Macros_Test_2.scala:6: error: macro defs must have explicitly specified return types
+ def foo5 = macro Impls.foo5
+ ^
+Macros_Test_2.scala:7: warning: macro defs must have explicitly specified return types (inference of Int from macro impl's c.Expr[Int] is deprecated and is going to stop working in 2.12)
+ def foo6 = macro Impls.foo6
+ ^
+Macros_Test_2.scala:14: error: exception during macro expansion:
+scala.NotImplementedError: an implementation is missing
+ at scala.Predef$.$qmark$qmark$qmark(Predef.scala:227)
+ at Impls$.foo3(Impls_1.scala:7)
+
+ foo3
+ ^
+Macros_Test_2.scala:15: error: macro implementation is missing
+ foo4
+ ^
+Macros_Test_2.scala:17: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses
+ foo6
+ ^
+two warnings found
+5 errors found
View
4 test/files/neg/macro-invalidret.flags
@@ -1 +1,3 @@
--language:experimental.macros
+-language:experimental.macros
+-Xfatal-warnings
+-deprecation
View
3 test/files/neg/macro-invalidret/Impls_1.scala
@@ -4,4 +4,7 @@ import scala.reflect.runtime.{universe => ru}
object Impls {
def foo1(c: BlackboxContext) = 2
def foo2(c: BlackboxContext) = ru.Literal(ru.Constant(42))
+ def foo3(c: BlackboxContext) = ???
+ def foo5(c: BlackboxContext) = c.universe.Literal(c.universe.Constant(42))
+ def foo6(c: BlackboxContext) = c.Expr[Int](c.universe.Literal(c.universe.Constant(42)))
}
View
8 test/files/neg/macro-invalidret/Macros_Test_2.scala
@@ -1,10 +1,18 @@
object Macros {
def foo1 = macro Impls.foo1
def foo2 = macro Impls.foo2
+ def foo3 = macro Impls.foo3
+ def foo4 = macro ???
+ def foo5 = macro Impls.foo5
+ def foo6 = macro Impls.foo6
}
object Test extends App {
import Macros._
foo1
foo2
+ foo3
+ foo4
+ foo5
+ foo6
}
View
2 test/files/neg/macro-invalidsig-params-badtype.check
@@ -1,5 +1,5 @@
Impls_Macros_1.scala:8: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Any]
+ required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Nothing]
or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree
found : (c: scala.reflect.macros.BlackboxContext)(x: Int): Nothing
type mismatch for parameter x: c.Expr[Int] does not conform to Int
View
30 test/files/neg/macro-invalidsig.check
@@ -1,29 +1,29 @@
Macros_Test_2.scala:2: error: macro implementations cannot have implicit parameters other than WeakTypeTag evidences
- def foo[U] = macro Impls1.foo[U]
- ^
+ def foo[U]: Int = macro Impls1.foo[U]
+ ^
Macros_Test_2.scala:6: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any]
+ required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing]
or : (c: scala.reflect.macros.BlackboxContext): c.Tree
found : : Nothing
number of parameter sections differ
def foo = macro Impls2.foo
^
Macros_Test_2.scala:10: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any]
+ required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing]
or : (c: scala.reflect.macros.BlackboxContext): c.Tree
found : (c: scala.reflect.api.Universe): Nothing
type mismatch for parameter c: scala.reflect.macros.BlackboxContext does not conform to scala.reflect.api.Universe
def foo = macro Impls3.foo
^
Macros_Test_2.scala:14: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any]
+ required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing]
or : (c: scala.reflect.macros.BlackboxContext): c.Tree
found : (cs: scala.reflect.macros.BlackboxContext*): Nothing
types incompatible for parameter cs: corresponding is not a vararg parameter
def foo = macro Impls4.foo
^
Macros_Test_2.scala:18: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Any]): c.Expr[Any]
+ required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Any]): c.Expr[Nothing]
or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree
found : (c: scala.reflect.macros.BlackboxContext): Nothing
number of parameter sections differ
@@ -33,35 +33,35 @@ Macros_Test_2.scala:22: error: macro implementations cannot have implicit parame
def foo[U](x: Int) = macro Impls6.foo[T, U]
^
Macros_Test_2.scala:26: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Any]
+ required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Nothing]
or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree
found : (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): Nothing
parameter lists have different length, found extra parameter y: c.Expr[Int]
def foo(x: Int) = macro Impls7.foo
^
Macros_Test_2.scala:30: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Any]
+ required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Nothing]
or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree
found : (c: scala.reflect.macros.BlackboxContext)(x: c.universe.Symbol): Nothing
type mismatch for parameter x: c.Expr[Int] does not conform to c.universe.Symbol
def foo(x: Int) = macro Impls8.foo
^
Macros_Test_2.scala:34: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Any]
+ required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Nothing]
or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree, y: c.Tree): c.Tree
found : (c: scala.reflect.macros.BlackboxContext)(xs: c.Expr[Int]*): Nothing
parameter lists have different length, required extra parameter y: c.Expr[Int]
def foo(x: Int, y: Int) = macro Impls9.foo
^
Macros_Test_2.scala:38: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Any]
+ required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Nothing]
or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree, y: c.Tree): c.Tree
found : (c: scala.reflect.macros.BlackboxContext)(y: c.Expr[Int], x: c.Expr[Int]): Nothing
parameter names differ: x != y
def foo(x: Int, y: Int) = macro Impls10.foo
^
Macros_Test_2.scala:42: error: macro implementation has incompatible shape:
- required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any]
+ required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing]
or : (c: scala.reflect.macros.BlackboxContext): c.Tree
found : (c: scala.reflect.macros.BlackboxContext)(U: c.universe.Type): Nothing
number of parameter sections differ
@@ -77,9 +77,9 @@ Macros_Test_2.scala:54: error: macro implementation reference has too few type a
def foo = macro Impls14.foo
^
Macros_Test_2.scala:59: error: macro implementation reference has too few type arguments for method foo: [T, U, V](c: scala.reflect.macros.BlackboxContext)(implicit evidence$5: c.WeakTypeTag[T], implicit evidence$6: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit]
- def foo15[V] = macro Impls15.foo
- ^
+ def foo15[V]: Unit = macro Impls15.foo
+ ^
Macros_Test_2.scala:60: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.BlackboxContext)(implicit evidence$7: c.WeakTypeTag[T], implicit evidence$8: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit]
- def foo16[V] = macro Impls16.foo[V]
- ^
+ def foo16[V]: Unit = macro Impls16.foo[V]
+ ^
16 errors found
View
6 test/files/neg/macro-invalidsig/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Macros1 {
- def foo[U] = macro Impls1.foo[U]
+ def foo[U]: Int = macro Impls1.foo[U]
}
object Macros2 {
@@ -56,8 +56,8 @@ object Macros14 {
class D[T] {
class C[U] {
- def foo15[V] = macro Impls15.foo
- def foo16[V] = macro Impls16.foo[V]
+ def foo15[V]: Unit = macro Impls15.foo
+ def foo16[V]: Unit = macro Impls16.foo[V]
}
}
View
2 test/files/neg/macro-invalidusage-badargs/Macros_Test_2.scala
@@ -1,4 +1,4 @@
-object Macros { def foo(x: Int) = macro Impls.foo }
+object Macros { def foo(x: Int): Int = macro Impls.foo }
import Macros._
object Test extends App {
View
2 test/files/neg/macro-invalidusage-badbounds/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Macros {
- def foo[U <: String] = macro Impls.foo[U]
+ def foo[U <: String]: Unit = macro Impls.foo[U]
}
object Test extends App {
View
10 test/files/neg/macro-invalidusage-badtargs.check
@@ -1,16 +1,16 @@
-Macros_Test_2.scala:11: error: macro method foo1: (x: Int)Int does not take type parameters.
+Macros_Test_2.scala:13: error: macro method foo1: (x: Int)Int does not take type parameters.
foo1[String](42)
^
-Macros_Test_2.scala:12: error: wrong number of type parameters for macro method foo2: [T](x: Int)Int
+Macros_Test_2.scala:14: error: wrong number of type parameters for macro method foo2: [T](x: Int)Int
foo2[String, String](42)
^
-Macros_Test_2.scala:13: error: wrong number of type parameters for macro method foo3: [T, U](x: Int)Int
+Macros_Test_2.scala:15: error: wrong number of type parameters for macro method foo3: [T, U](x: Int)Int
foo3[String](42)
^
-Macros_Test_2.scala:14: error: String takes no type parameters, expected: one
+Macros_Test_2.scala:16: error: String takes no type parameters, expected: one
foo4[String](42)
^
-Macros_Test_2.scala:15: error: kinds of the type arguments (List) do not conform to the expected kinds of the type parameters (type T).
+Macros_Test_2.scala:17: error: kinds of the type arguments (List) do not conform to the expected kinds of the type parameters (type T).
List's type parameters do not match type T's expected parameters:
type A has no type parameters, but type U has one
foo5[List](42)
View
12 test/files/neg/macro-invalidusage-badtargs/Macros_Test_2.scala
@@ -1,9 +1,11 @@
+import scala.language.higherKinds
+
object Macros {
- def foo1(x: Int) = macro Impls.foo
- def foo2[T](x: Int) = macro Impls.foo
- def foo3[T, U](x: Int) = macro Impls.foo
- def foo4[T[_]](x: Int) = macro Impls.foo
- def foo5[T[U[_]]](x: Int) = macro Impls.foo
+ def foo1(x: Int): Int = macro Impls.foo
+ def foo2[T](x: Int): Int = macro Impls.foo
+ def foo3[T, U](x: Int): Int = macro Impls.foo
+ def foo4[T[_]](x: Int): Int = macro Impls.foo
+ def foo5[T[U[_]]](x: Int): Int = macro Impls.foo
}
object Test extends App {
View
2 test/files/neg/macro-invalidusage-methodvaluesyntax/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Macros {
- def foo = macro Impls.foo
+ def foo: Unit = macro Impls.foo
}
object Test extends App {
View
2 test/files/neg/macro-override-macro-overrides-abstract-method-a.check
@@ -1,5 +1,5 @@
Impls_Macros_1.scala:12: error: overriding method foo in trait Foo of type (x: Int)Int;
macro method foo cannot be used here - term macros cannot override abstract methods
- def foo(x: Int) = macro Impls.impl
+ def foo(x: Int): Int = macro Impls.impl
^
one error found
View
2 test/files/neg/macro-override-macro-overrides-abstract-method-a/Impls_Macros_1.scala
@@ -9,5 +9,5 @@ trait Foo {
}
object Macros extends Foo {
- def foo(x: Int) = macro Impls.impl
+ def foo(x: Int): Int = macro Impls.impl
}
View
2 test/files/neg/macro-override-method-overrides-macro.check
@@ -1,5 +1,5 @@
Macros_Test_2.scala:8: error: overriding macro method foo in class B of type (x: String)Unit;
method foo cannot be used here - only term macros can override term macros
- override def foo(x: String) = println("fooDString")
+ override def foo(x: String): Unit = println("fooDString")
^
one error found
View
14 test/files/neg/macro-override-method-overrides-macro/Macros_Test_2.scala
@@ -1,15 +1,15 @@
class B {
- def foo(x: String) = macro Impls.fooBString
- def foo(x: Int) = macro Impls.fooBInt
- def foo(x: Boolean) = println("fooBBoolean")
+ def foo(x: String): Unit = macro Impls.fooBString
+ def foo(x: Int): Unit = macro Impls.fooBInt
+ def foo(x: Boolean): Unit = println("fooBBoolean")
}
class D extends B {
- override def foo(x: String) = println("fooDString")
- override def foo(x: Int) = macro Impls.fooDInt
+ override def foo(x: String): Unit = println("fooDString")
+ override def foo(x: Int): Unit = macro Impls.fooDInt
}
class Z extends D {
- override def foo(x: String) = macro Impls.fooZString
- override def foo(x: Boolean) = println("fooZBoolean")
+ override def foo(x: String): Unit = macro Impls.fooZString
+ override def foo(x: Boolean): Unit = println("fooZBoolean")
}
View
6 test/files/neg/macro-quasiquotes.check
@@ -1,8 +1,8 @@
Macros_1.scala:14: error: macro implementation has incompatible shape:
- required: (x: Impls.this.c.Expr[Int]): Impls.this.c.Expr[Any]
+ required: (x: Impls.this.c.Expr[Int]): Impls.this.c.Expr[Unit]
or : (x: Impls.this.c.Tree): Impls.this.c.Tree
found : (x: Impls.this.c.universe.Block): Impls.this.c.Tree
type mismatch for parameter x: Impls.this.c.Expr[Int] does not conform to Impls.this.c.universe.Block
- def m3(x: Int) = macro Impls.impl3
- ^
+ def m3(x: Int): Unit = macro Impls.impl3
+ ^
one error found
View
6 test/files/neg/macro-quasiquotes/Macros_1.scala
@@ -9,7 +9,7 @@ trait Impls extends BlackboxMacro {
}
object Macros {
- def m1(x: Int) = macro Impls.impl1
- def m2(x: Int) = macro Impls.impl2
- def m3(x: Int) = macro Impls.impl3
+ def m1(x: Int): Unit = macro Impls.impl1
+ def m2(x: Int): Unit = macro Impls.impl2
+ def m3(x: Int): Unit = macro Impls.impl3
}
View
2 test/files/neg/t5753/Impls_Macros_1.scala
@@ -1,6 +1,6 @@
import scala.reflect.macros.{BlackboxContext => Ctx}
trait Impls {
-def impl(c: Ctx)(x: c.Expr[Any]) = x
+ def impl(c: Ctx)(x: c.Expr[Any]) = x
}
View
2 test/files/neg/t5753/Test_2.scala
@@ -1,7 +1,7 @@
import scala.reflect.macros.{BlackboxContext => Ctx}
object Macros extends Impls {
- def foo(x: Any) = macro impl
+ def foo(x: Any): Any = macro impl
}
object Test extends App {
View
2 test/files/neg/t5903a/Macros_1.scala
@@ -7,7 +7,7 @@ case object SomeTree extends Tree
object NewQuasiquotes {
implicit class QuasiquoteInterpolation(c: StringContext) {
object nq {
- def unapply(t: Tree) = macro QuasiquoteMacros.unapplyImpl
+ def unapply(t: Tree): Any = macro QuasiquoteMacros.unapplyImpl
}
}
}
View
2 test/files/neg/t5903b/Macros_1.scala
@@ -4,7 +4,7 @@ import language.experimental.macros
object Interpolation {
implicit class TestInterpolation(c: StringContext) {
object t {
- def unapply[T](x: T) = macro Macros.unapplyImpl[T]
+ def unapply[T](x: T): Any = macro Macros.unapplyImpl[T]
}
}
}
View
2 test/files/neg/t5903c/Macros_1.scala
@@ -4,7 +4,7 @@ import language.experimental.macros
object Interpolation {
implicit class TestInterpolation(c: StringContext) {
object t {
- def unapply[T](x: T) = macro Macros.unapplyImpl[T]
+ def unapply[T](x: T): Any = macro Macros.unapplyImpl[T]
}
}
}
View
2 test/files/neg/t5903d/Macros_1.scala
@@ -4,7 +4,7 @@ import language.experimental.macros
object Interpolation {
implicit class TestInterpolation(c: StringContext) {
object t {
- def unapply(x: Int) = macro Macros.unapplyImpl
+ def unapply(x: Int): Any = macro Macros.unapplyImpl
}
}
}
View
2 test/files/neg/t5903e/Macros_1.scala
@@ -4,7 +4,7 @@ import language.experimental.macros
object Interpolation {
implicit class TestInterpolation(c: StringContext) {
object t {
- def unapply(x: Int) = macro Macros.unapplyImpl
+ def unapply(x: Int): Any = macro Macros.unapplyImpl
}
}
}
View
2 test/files/neg/t7519-b.check
@@ -1,4 +1,4 @@
-Use_2.scala:6: error: type mismatch;
+Use_2.scala:8: error: type mismatch;
found : String
required: Q
val x: Q = ex.Mac.mac("asdf")
View
2 test/files/neg/t7519-b/Use_2.scala
@@ -1,3 +1,5 @@
+import scala.language.implicitConversions
+
trait Q
trait K
View
2 test/files/pos/t8001/Macros_1.scala
@@ -2,7 +2,7 @@ import scala.language.experimental.macros
import scala.reflect.macros.BlackboxContext
object Macros {
- def foo = macro impl
+ def foo: Unit = macro impl
def impl(c: BlackboxContext) = {
import c.universe._
q"()"
View
2 test/files/run/macro-bodyexpandstoimpl/Impls_1.scala
@@ -4,7 +4,7 @@ import scala.reflect.macros.{BlackboxContext, WhiteboxContext}
object Impls {
def foo(c: BlackboxContext)(x: c.Expr[Int]) = x
- def refToFoo(dummy: Int) = macro refToFoo_impl
+ def refToFoo(dummy: Int): Int = macro refToFoo_impl
def refToFoo_impl(c: WhiteboxContext)(dummy: c.Expr[Int]) = {
import c.universe._
val body = Select(Ident(TermName("Impls")), TermName("foo"))
View
2 test/files/run/macro-bodyexpandstoimpl/Macros_Test_2.scala
@@ -1,7 +1,7 @@
import scala.language.experimental.macros
object Macros {
- def foo(x: Int) = macro Impls.refToFoo(42)
+ def foo(x: Int): Int = macro Impls.refToFoo(42)
}
object Test extends App {
View
4 test/files/run/macro-bundle-repl.check
@@ -7,7 +7,7 @@ import scala.language.experimental.macros
scala> import scala.reflect.macros.BlackboxMacro
import scala.reflect.macros.BlackboxMacro
-scala> trait Bar extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar = macro Bar.impl
+scala> trait Bar extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar: Unit = macro Bar.impl
defined trait Bar
defined term macro bar: Unit
@@ -16,7 +16,7 @@ scala> bar
scala> trait Foo extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } }
defined trait Foo
-scala> def foo = macro Foo.impl
+scala> def foo: Unit = macro Foo.impl
defined term macro foo: Unit
scala> foo
View
4 test/files/run/macro-bundle-repl.scala
@@ -4,10 +4,10 @@ object Test extends ReplTest {
def code = """
import scala.language.experimental.macros
import scala.reflect.macros.BlackboxMacro
-trait Bar extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar = macro Bar.impl
+trait Bar extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar: Unit = macro Bar.impl
bar
trait Foo extends BlackboxMacro { def impl = { import c.universe._; c.Expr[Unit](q"()") } }
-def foo = macro Foo.impl
+def foo: Unit = macro Foo.impl
foo
"""
}
View
8 test/files/run/macro-def-infer-return-type.check
@@ -1,8 +0,0 @@
-42
-reflective compilation has failed:
-
-exception during macro expansion:
-java.lang.Error: an implementation is missing
- at Impls2$.foo(Impls_1.scala:9)
-
-42
View
1 test/files/run/macro-def-infer-return-type.flags
@@ -1 +0,0 @@
--language:experimental.macros
View
14 test/files/run/macro-def-infer-return-type/Impls_1.scala
@@ -1,14 +0,0 @@
-import scala.reflect.macros.BlackboxContext
-
-object Impls1 {
- def foo(c: BlackboxContext)(x: c.Expr[Int]) = x
-}
-
-object Impls2 {
- def foo[T](c: BlackboxContext)(x: c.Expr[T]) =
- throw new Error("an implementation is missing")
-}
-
-object Impls3 {
- def foo[T](c: BlackboxContext)(x: c.Expr[T]): c.Expr[T] = x
-}
View
24 test/files/run/macro-def-infer-return-type/Macros_Test_2.scala
@@ -1,24 +0,0 @@
-object Macros1 {
- def foo(x: Int) = macro Impls1.foo
-}
-
-object Macros2 {
- def foo[T](x: T) = macro Impls2.foo[T]
-}
-
-object Macros3 {
- def foo[T](x: T) = macro Impls3.foo[T]
-}
-
-object Test extends App {
- println(Macros1.foo(42))
-
- import scala.reflect.runtime.universe._
- import scala.reflect.runtime.{currentMirror => cm}
- import scala.tools.reflect.ToolBox
- val tree = Apply(Select(Ident(TermName("Macros2")), TermName("foo")), List(Literal(Constant(42))))
- try cm.mkToolBox().eval(tree)
- catch { case ex: Throwable => println(ex.getMessage) }
-
- println(Macros3.foo(42))
-}
View
48 test/files/run/macro-def-path-dependent/Test_1.scala
@@ -1,23 +1,25 @@
-package test1
-
-import scala.reflect.macros.{BlackboxContext => Ctx}
-
-trait Exprs {
- self: Universe =>
-
- class Expr[T]
-}
-
-trait Reifiers {
- self: Universe =>
-
- type Expr[T]
-
- def reify[T](expr: T) = macro Impls.reify[T]
-}
-
-trait Universe extends Exprs with Reifiers
-
-object Impls {
- def reify[T](cc: Ctx{ type PrefixType = Reifiers })(expr: cc.Expr[T]): cc.Expr[cc.prefix.value.Expr[T]] = ???
-}
+// NOTE: blocked by SI-8049
+
+// package test1
+//
+// import scala.reflect.macros.{BlackboxContext => Ctx}
+//
+// trait Exprs {
+// self: Universe =>
+//
+// class Expr[T]
+// }
+//
+// trait Reifiers {
+// self: Universe =>
+//
+// type Expr[T]
+//
+// def reify[T](expr: T): Expr[T] = macro Impls.reify[T]
+// }
+//
+// trait Universe extends Exprs with Reifiers
+//
+// object Impls {
+// def reify[T](cc: Ctx{ type PrefixType = Reifiers })(expr: cc.Expr[T]): cc.Expr[cc.prefix.value.Expr[T]] = ???
+// }
View
2 test/files/run/macro-def-path-dependent/Test_2.scala
@@ -14,7 +14,7 @@ trait Reifiers {
}
trait Universe extends Exprs with Reifiers {
- def reify[T](expr: T) = macro Impls.reify[T]
+ def reify[T](expr: T): Expr[T] = macro Impls.reify[T]
}
object Impls {
View
2 test/files/run/macro-def-path-dependent/Test_4.scala
@@ -5,7 +5,7 @@ import scala.reflect.macros.BlackboxContext
import scala.reflect.api.Universe
object Test {
- def materializeTypeTag[T](u: Universe)(e: T) = macro materializeTypeTag_impl[T]
+ def materializeTypeTag[T](u: Universe)(e: T): u.TypeTag[T] = macro materializeTypeTag_impl[T]
def materializeTypeTag_impl[T: c.WeakTypeTag](c: BlackboxContext)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ???
}
View
2 test/files/run/macro-def-path-dependent/Test_6.scala
@@ -5,5 +5,5 @@ import scala.reflect.macros.BlackboxContext
import scala.reflect.api.Universe
object Macros {
- def materializeTypeTag[T](u: Universe)(e: T) = macro Impls.materializeTypeTag_impl[T]
+ def materializeTypeTag[T](u: Universe)(e: T): u.TypeTag[T] = macro Impls.materializeTypeTag_impl[T]
}
View
2 test/files/run/macro-expand-implicit-macro-has-implicit/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Test extends App {
implicit val x = 42
- def foo(implicit x: Int) = macro Impls.foo
+ def foo(implicit x: Int): Unit = macro Impls.foo
foo
}
View
2 test/files/run/macro-expand-implicit-macro-is-val/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Test extends App {
- implicit def foo = macro Impls.foo
+ implicit def foo: Int = macro Impls.foo
def bar(implicit x: Int) = println(x)
bar
}
View
2 test/files/run/macro-expand-multiple-arglists/Macros_Test_2.scala
@@ -1,4 +1,4 @@
object Test extends App {
- def foo(x: Int)(y: Int) = macro Impls.foo
+ def foo(x: Int)(y: Int): Unit = macro Impls.foo
foo(40)(2)
}
View
8 test/files/run/macro-expand-nullary-generic/Macros_Test_2.scala
@@ -1,8 +1,8 @@
object Macros {
- def foo1[T] = macro Impls.fooNullary[T]
- def foo2[T]() = macro Impls.fooEmpty[T]
- def bar1[T](x: Int) = macro Impls.barNullary[T]
- def bar2[T](x: Int)() = macro Impls.barEmpty[T]
+ def foo1[T]: Unit = macro Impls.fooNullary[T]
+ def foo2[T](): Unit = macro Impls.fooEmpty[T]
+ def bar1[T](x: Int): Unit = macro Impls.barNullary[T]
+ def bar2[T](x: Int)(): Unit = macro Impls.barEmpty[T]
}
object Test extends App {
View
8 test/files/run/macro-expand-nullary-nongeneric/Macros_Test_2.scala
@@ -1,8 +1,8 @@
object Macros {
- def foo1 = macro Impls.fooNullary
- def foo2() = macro Impls.fooEmpty
- def bar1(x: Int) = macro Impls.barNullary
- def bar2(x: Int)() = macro Impls.barEmpty
+ def foo1: Unit = macro Impls.fooNullary
+ def foo2(): Unit = macro Impls.fooEmpty
+ def bar1(x: Int): Unit = macro Impls.barNullary
+ def bar2(x: Int)(): Unit = macro Impls.barEmpty
}
object Test extends App {
View
12 test/files/run/macro-expand-overload/Macros_Test_2.scala
@@ -1,13 +1,13 @@
object Macros {
- def foo(x: String) = macro Impls.fooObjectString
- def foo(x: Int) = macro Impls.fooObjectInt
- def foo(x: Boolean) = println("fooObjectBoolean")
+ def foo(x: String): Unit = macro Impls.fooObjectString
+ def foo(x: Int): Unit = macro Impls.fooObjectInt
+ def foo(x: Boolean): Unit = println("fooObjectBoolean")
}
class Macros {
- def foo(x: String) = macro Impls.fooClassString
- def foo(x: Int) = macro Impls.fooClassInt
- def foo(x: Boolean) = println("fooClassBoolean")
+ def foo(x: String): Unit = macro Impls.fooClassString
+ def foo(x: Int): Unit = macro Impls.fooClassInt
+ def foo(x: Boolean): Unit = println("fooClassBoolean")
}
object Test extends App {
View
14 test/files/run/macro-expand-override/Macros_Test_2.scala
@@ -1,17 +1,17 @@
class B {
- def foo(x: String) = macro Impls.fooBString
- def foo(x: Int) = macro Impls.fooBInt
- def foo(x: Boolean) = println("fooBBoolean")
+ def foo(x: String): Unit = macro Impls.fooBString
+ def foo(x: Int): Unit = macro Impls.fooBInt
+ def foo(x: Boolean): Unit = println("fooBBoolean")
}
class D extends B {
- //override def foo(x: String) = println("fooDString") => method cannot override a macro
- override def foo(x: Int) = macro Impls.fooDInt
+ //override def foo(x: String): Unit = println("fooDString") => method cannot override a macro
+ override def foo(x: Int): Unit = macro Impls.fooDInt
}
class Z extends D {
- override def foo(x: String) = macro Impls.fooZString
- override def foo(x: Boolean) = println("fooZBoolean")
+ override def foo(x: String): Unit = macro Impls.fooZString
+ override def foo(x: Boolean): Unit = println("fooZBoolean")
}
object Test extends App {
View
4 test/files/run/macro-expand-recursive/Macros_Test_2.scala
@@ -1,6 +1,6 @@
object Macros {
- def foo = macro Impls.foo
- def fooFoo = macro Impls.fooFoo
+ def foo: Unit = macro Impls.foo
+ def fooFoo: Unit = macro Impls.fooFoo
}
object Test extends App {
View
4 test/files/run/macro-expand-tparams-bounds/Macros_Test_2.scala
@@ -1,9 +1,9 @@
object Macros1 {
- def foo[U <: String] = macro Impls1.foo[U]
+ def foo[U <: String]: Unit = macro Impls1.foo[U]
}
object Macros2 {
- def foo[T <: D] = macro Impls2.foo[T]
+ def foo[T <: D]: Unit = macro Impls2.foo[T]
}
object Test extends App {
View
2 test/files/run/macro-expand-tparams-explicit/Macros_Test_2.scala
@@ -1,4 +1,4 @@
object Test extends App {
- def foo[U] = macro Impls.foo[U]
+ def foo[U]: Unit = macro Impls.foo[U]
foo[Int]
}
View
2 test/files/run/macro-expand-tparams-implicit/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Test extends App {
- def foo[U](x: U) = macro Impls.foo[U]
+ def foo[U](x: U): Unit = macro Impls.foo[U]
foo(42)
foo("42")
}
View
8 test/files/run/macro-expand-tparams-prefix/Macros_Test_2.scala
@@ -1,19 +1,19 @@
object Macros1 {
class C[T] {
- def foo[U](x: U) = macro Impls1.foo[U]
+ def foo[U](x: U): Unit = macro Impls1.foo[U]
}
}
object Macros2 {
class C[T] {
- def foo[U](x: U) = macro Impls2.foo[T, U]
+ def foo[U](x: U): Unit = macro Impls2.foo[T, U]
}
}
object Macros3 {
class D[T] {
class C[U] {
- def foo[V] = macro Impls345.foo[T, U, V]
+ def foo[V]: Unit = macro Impls345.foo[T, U, V]
}
}
}
@@ -23,7 +23,7 @@ object Macros3 {
object Macros5 {
class D[T] {
class C[U] {
- def foo[V] = macro Impls345.foo[T, U, V]
+ def foo[V]: Unit = macro Impls345.foo[T, U, V]
foo[Boolean]
}
}
View
2 test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Macros {
- def foo(xs: Int*) = macro Impls.foo
+ def foo(xs: Int*): Unit = macro Impls.foo
}
object Test extends App {
View
2 test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Macros {
- def foo(xs: Int*) = macro Impls.foo
+ def foo(xs: Int*): Unit = macro Impls.foo
}
object Test extends App {
View
2 test/files/run/macro-expand-varargs-explicit-over-varargs/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Macros {
- def foo(xs: Int*) = macro Impls.foo
+ def foo(xs: Int*): Unit = macro Impls.foo
}
object Test extends App {
View
2 test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Macros {
- def foo(xs: Int*) = macro Impls.foo
+ def foo(xs: Int*): Unit = macro Impls.foo
}
object Test extends App {
View
2 test/files/run/macro-expand-varargs-implicit-over-varargs/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Macros {
- def foo(xs: Int*) = macro Impls.foo
+ def foo(xs: Int*): Unit = macro Impls.foo
}
object Test extends App {
View
2 test/files/run/macro-impl-tparam-only-in-impl/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Macros {
- def foo = macro Impls.foo[String]
+ def foo: Unit = macro Impls.foo[String]
}
object Test extends App {
View
2 test/files/run/macro-impl-tparam-typetag-is-optional/Macros_Test_2.scala
@@ -1,4 +1,4 @@
object Test extends App {
- def foo[U] = macro Impls.foo[U]
+ def foo[U]: Unit = macro Impls.foo[U]
foo[Int]
}
View
6 test/files/run/macro-quasiquotes/Macros_1.scala
@@ -9,7 +9,7 @@ trait Impls extends BlackboxMacro {
}
object Macros {
- def m1 = macro Impls.impl1
- def m2 = macro Impls.impl2
- def m3 = macro Impls.impl3
+ def m1: Unit = macro Impls.impl1
+ def m2: Unit = macro Impls.impl2
+ def m3: Int = macro Impls.impl3
}
View
1 test/files/run/macro-reflective-mamd-normal-mi.check
@@ -1,2 +1 @@
-warning: there were 1 deprecation warning(s); re-run with -deprecation for details
43
View
4 test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala
@@ -10,9 +10,9 @@ object Test extends App {
val macrobody = Select(Ident(TermName("Impls")), TermName("foo"))
val macroparam = ValDef(NoMods, TermName("x"), TypeTree(definitions.IntClass.toType), EmptyTree)
- val macrodef = DefDef(Modifiers(MACRO), TermName("foo"), Nil, List(List(macroparam)), TypeTree(), macrobody)
+ val macrodef = DefDef(Modifiers(MACRO), TermName("foo"), Nil, List(List(macroparam)), Ident(TypeName("Int")), macrobody)
val modulector = DefDef(NoMods, nme.CONSTRUCTOR, Nil, List(List()), TypeTree(), Block(List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), Literal(Constant(()))))
- val module = ModuleDef(NoMods, TermName("Macros"), Template(Nil, emptyValDef, List(modulector, macrodef)))
+ val module = ModuleDef(NoMods, TermName("Macros"), Template(Nil, noSelfType, List(modulector, macrodef)))
val macroapp = Apply(Select(Ident(TermName("Macros")), TermName("foo")), List(Literal(Constant(42))))
val tree = Block(List(macrodef, module), macroapp)
val toolbox = cm.mkToolBox(options = "-language:experimental.macros")
View
2 test/files/run/macro-reify-ref-to-packageless/Test_2.scala
@@ -1,4 +1,4 @@
object Test extends App {
- def foo = macro Impls.foo
+ def foo: Int = macro Impls.foo
println(foo)
}
View
4 test/files/run/macro-repl-dontexpand.check
@@ -5,12 +5,12 @@ scala> def bar1(c: scala.reflect.macros.BlackboxContext) = ???
bar1: (c: scala.reflect.macros.BlackboxContext)Nothing
scala> def foo1 = macro bar1
-defined term macro foo1: Any
+defined term macro foo1: Nothing
scala> def bar2(c: scala.reflect.macros.WhiteboxContext) = ???
bar2: (c: scala.reflect.macros.WhiteboxContext)Nothing
scala> def foo2 = macro bar2
-defined term macro foo2: Any
+defined term macro foo2: Nothing
scala>
View
2 test/files/run/macro-system-properties.check
@@ -9,7 +9,7 @@ scala> object GrabContext {
def lastContext = Option(System.getProperties.get("lastContext").asInstanceOf[reflect.macros.runtime.Context])
// System.properties lets you stash true globals (unlike statics which are classloader scoped)
def impl(c: BlackboxContext)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") }
- def grab() = macro impl
+ def grab(): Unit = macro impl
}
defined object GrabContext
View
2 test/files/run/macro-system-properties.scala
@@ -8,7 +8,7 @@ object Test extends ReplTest {
def lastContext = Option(System.getProperties.get("lastContext").asInstanceOf[reflect.macros.runtime.Context])
// System.properties lets you stash true globals (unlike statics which are classloader scoped)
def impl(c: BlackboxContext)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") }
- def grab() = macro impl
+ def grab(): Unit = macro impl
}
object Test { class C(implicit a: Any) { GrabContext.grab } }
object Test { class C(implicit a: Any) { GrabContext.grab } }
View
2 test/files/run/macro-term-declared-in-anonymous/Macros_Test_2.scala
@@ -1,6 +1,6 @@
import scala.language.reflectiveCalls
object Test extends App {
- val macros = new { def foo = macro Impls.foo }
+ val macros = new { def foo: Unit = macro Impls.foo }
macros.foo
}
View
2 test/files/run/macro-term-declared-in-block/Macros_Test_2.scala
@@ -1,6 +1,6 @@
object Test extends App {
{
- def foo = macro Impls.foo
+ def foo: Unit = macro Impls.foo
foo
}
}
View
2 test/files/run/macro-term-declared-in-class-class/Macros_Test_2.scala
@@ -1,6 +1,6 @@
class Macros {
class Macros {
- def foo = macro Impls.foo
+ def foo: Unit = macro Impls.foo
}
}
View
2 test/files/run/macro-term-declared-in-class-object/Macros_Test_2.scala
@@ -1,6 +1,6 @@
class Macros {
object Macros {
- def foo = macro Impls.foo
+ def foo: Unit = macro Impls.foo
}
}
View
2 test/files/run/macro-term-declared-in-class/Macros_Test_2.scala
@@ -1,5 +1,5 @@
class Macros {
- def foo = macro Impls.foo
+ def foo: Unit = macro Impls.foo
}
object Test extends App {
View
2 test/files/run/macro-term-declared-in-default-param/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Test extends App {
- def foo(bar: String = { def foo = macro Impls.foo; foo }) = println(bar)
+ def foo(bar: String = { def foo: String = macro Impls.foo; foo }) = println(bar)
foo()
foo("it works")
View
2 test/files/run/macro-term-declared-in-method/Macros_Test_2.scala
@@ -1,6 +1,6 @@
object Test extends App {
def bar() = {
- def foo = macro Impls.foo
+ def foo: Unit = macro Impls.foo
foo
}
View
2 test/files/run/macro-term-declared-in-object-class/Macros_Test_2.scala
@@ -1,6 +1,6 @@
object Macros {
class Macros {
- def foo = macro Impls.foo
+ def foo: Unit = macro Impls.foo
}
}
View
2 test/files/run/macro-term-declared-in-object-object/Macros_Test_2.scala
@@ -1,6 +1,6 @@
object Macros {
object Macros {
- def foo = macro Impls.foo
+ def foo: Unit = macro Impls.foo
}
}
View
2 test/files/run/macro-term-declared-in-object/Macros_Test_2.scala
@@ -1,5 +1,5 @@
object Macros {
- def foo = macro Impls.foo
+ def foo: Unit = macro Impls.foo
}
object Test extends App {
View
2 test/files/run/macro-term-declared-in-package-object/Macros_Test_2.scala
@@ -1,5 +1,5 @@
package object Macros {
- def foo = macro Impls.foo
+ def foo: Unit = macro Impls.foo
}
object Test extends App {
View
3 test/files/run/macro-term-declared-in-refinement/Macros_Test_2.scala
@@ -1,9 +1,8 @@
-
import scala.language.reflectiveCalls
class Base
object Test extends App {
- val macros = new Base { def foo = macro Impls.foo }
+ val macros = new Base { def foo: Unit = macro Impls.foo }
macros.foo
}
View
2 test/files/run/macro-term-declared-in-trait/Macros_Test_2.scala
@@ -1,5 +1,5 @@
trait Base {
- def foo = macro Impls.foo
+ def foo: Unit = macro Impls.foo
}
object Macros extends Base
View
4 test/files/run/macro-vampire-false-warning/Macros_1.scala
@@ -22,7 +22,7 @@ object Macros {
// val fields = kvps map { case (k, v) => q"@body($v) def ${TermName(k)} = macro Macros.selFieldImpl" }
val fields = kvps map { case (k, v) => DefDef(
Modifiers(MACRO, tpnme.EMPTY, List(Apply(Select(New(Ident(TypeName("body"))), nme.CONSTRUCTOR), List(v)))),
- TermName(k), Nil, Nil, TypeTree(), Select(Ident(TermName("Macros")), TermName("selFieldImpl"))) }
+ TermName(k), Nil, Nil, Ident(TypeName("Any")), Select(Ident(TermName("Macros")), TermName("selFieldImpl"))) }
// q"import scala.language.experimental.macros; class Workaround { ..$fields }; new Workaround{}"
c.Expr[Any](Block(
List(
@@ -48,5 +48,5 @@ object Macros {
}
object mkObject {
- def apply(xs: Any*) = macro Macros.mkObjectImpl
+ def apply(xs: Any*): Any = macro Macros.mkObjectImpl
}
View
2 test/files/run/macro-whitebox-extractor/Macros_1.scala
@@ -2,7 +2,7 @@ import scala.reflect.macros.WhiteboxContext
import language.experimental.macros
object Extractor {
- def unapply(x: Int) = macro Macros.unapplyImpl
+ def unapply(x: Int): Any = macro Macros.unapplyImpl
}
object Macros {
View
2 test/files/run/macro-whitebox-structural/Impls_Macros_1.scala
@@ -12,5 +12,5 @@ object Macros {
"""
}
- def foo = macro impl
+ def foo: Any = macro impl
}
View
6 test/files/run/repl-term-macros.check
@@ -12,7 +12,7 @@ scala>
scala> def impl1(c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") }
impl1: (c: scala.reflect.macros.BlackboxContext)c.Expr[Unit]
-scala> def foo1 = macro impl1
+scala> def foo1: Unit = macro impl1
defined term macro foo1: Unit
scala> foo1
@@ -22,7 +22,7 @@ scala>
scala> def impl2(c: BlackboxContext)() = { import c.universe._; c.Expr[Unit](q"()") }
impl2: (c: scala.reflect.macros.BlackboxContext)()c.Expr[Unit]
-scala> def foo2() = macro impl2
+scala> def foo2(): Unit = macro impl2
defined term macro foo2: ()Unit
scala> foo2()
@@ -32,7 +32,7 @@ scala>
scala> def impl3(c: BlackboxContext)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") }
impl3: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int])(y: c.Expr[Int])c.Expr[Unit]
-scala> def foo3(x: Int)(y: Int) = macro impl3
+scala> def foo3(x: Int)(y: Int): Unit = macro impl3
defined term macro foo3: (x: Int)(y: Int)Unit
scala> foo3(2)(3)
View
6 test/files/run/repl-term-macros.scala
@@ -6,15 +6,15 @@ object Test extends ReplTest {
import language.experimental.macros
def impl1(c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") }
-def foo1 = macro impl1
+def foo1: Unit = macro impl1
foo1
def impl2(c: BlackboxContext)() = { import c.universe._; c.Expr[Unit](q"()") }
-def foo2() = macro impl2
+def foo2(): Unit = macro impl2
foo2()
def impl3(c: BlackboxContext)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") }
-def foo3(x: Int)(y: Int) = macro impl3
+def foo3(x: Int)(y: Int): Unit = macro impl3
foo3(2)(3)
"""
}
View
2 test/files/run/t5894.scala
@@ -3,7 +3,7 @@ import language.experimental.macros
class Test
object Test {
- def foo = macro fooImpl
+ def foo: Unit = macro fooImpl
def fooImpl(c: reflect.macros.BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") }
def main(args: Array[String]) {
View
2 test/files/run/t5903a/Macros_1.scala
@@ -7,7 +7,7 @@ case object SomeTree extends Tree
object NewQuasiquotes {
implicit class QuasiquoteInterpolation(c: StringContext) {
object nq {
- def unapply(t: Tree) = macro QuasiquoteMacros.unapplyImpl
+ def unapply(t: Tree): Any = macro QuasiquoteMacros.unapplyImpl
}
}
}
View
2 test/files/run/t5903b/Macros_1.scala
@@ -4,7 +4,7 @@ import language.experimental.macros
object Interpolation {
implicit class TestInterpolation(c: StringContext) {
object t {
- def unapply[T](x: T) = macro Macros.unapplyImpl[T]
+ def unapply[T](x: T): Any = macro Macros.unapplyImpl[T]
}
}
}
View
2 test/files/run/t5903c/Macros_1.scala
@@ -4,7 +4,7 @@ import language.experimental.macros
object Interpolation {
implicit class TestInterpolation(c: StringContext) {
object t {
- def unapply[T](x: T) = macro Macros.unapplyImpl[T]
+ def unapply[T](x: T): Any = macro Macros.unapplyImpl[T]
}
}
}
View
2 test/files/run/t5903d/Macros_1.scala
@@ -4,7 +4,7 @@ import language.experimental.macros
object Interpolation {
implicit class TestInterpolation(c: StringContext) {
object t {
- def unapply(x: Int) = macro Macros.unapplyImpl
+ def unapply(x: Int): Any = macro Macros.unapplyImpl
}
}
}
View
2 test/files/run/t5940.scala
@@ -13,7 +13,7 @@ object Test extends DirectTest {
object Macros {
//import Impls._
def impl(c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") }
- def foo = macro impl
+ def foo: Unit = macro impl
}
"""
def compileMacros() = {
View
2 test/files/run/t6381.check
@@ -10,7 +10,7 @@ scala> def pos_impl(c: reflect.macros.BlackboxContext): c.Expr[String] = {
}
pos_impl: (c: scala.reflect.macros.BlackboxContext)c.Expr[String]
-scala> def pos = macro pos_impl
+scala> def pos: String = macro pos_impl
defined term macro pos: String
scala> pos
View
2 test/files/run/t6381.scala
@@ -7,7 +7,7 @@ object Test extends ReplTest {
| import c.universe._
| c.Expr[String](Literal(Constant(c.enclosingPosition.getClass.toString)))
|}
- |def pos = macro pos_impl
+ |def pos: String = macro pos_impl
|pos
|""".stripMargin.trim
View
2 test/files/run/t7617b/Test_2.scala
@@ -2,7 +2,7 @@ import scala.language.dynamics
import language.experimental.macros
class C extends Dynamic {
- def updateDynamic(name: String)(value: Any) = macro Macros.impl
+ def updateDynamic(name: String)(value: Any): Unit = macro Macros.impl
}
object Test extends App {
View
2 test/files/run/t7871/Macros_1.scala
@@ -7,7 +7,7 @@ case object SomeTree extends Tree
object NewQuasiquotes {
implicit class QuasiquoteInterpolation(c: StringContext) {
object nq {
- def unapply(t: Tree) = macro QuasiquoteMacros.unapplyImpl
+ def unapply(t: Tree): Any = macro QuasiquoteMacros.unapplyImpl
}
}
}
View
2 test/files/run/toolbox_current_run_compiles.scala
@@ -9,7 +9,7 @@ package pkg {
val g = c.universe.asInstanceOf[scala.tools.nsc.Global]
c.Expr[Boolean](Literal(Constant(g.currentRun.compiles(sym.asInstanceOf[g.Symbol]))))
}
- def compiles[T] = macro impl[T]
+ def compiles[T]: Boolean = macro impl[T]
}
}
View
6 test/scaladoc/run/SI-6812.scala
@@ -5,12 +5,12 @@ import language._
object Test extends ScaladocModelTest {
override def code = """
- import scala.reflect.macros.Context
+ import scala.reflect.macros.BlackboxContext
import language.experimental.macros
object Macros {
- def impl(c: Context) = c.literalUnit
- def foo = macro impl
+ def impl(c: BlackboxContext) = c.literalUnit
+ def foo: Unit = macro impl
}
class C {

0 comments on commit 87979ad

Please sign in to comment.