diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2013-10-02 16:34:59 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2013-10-02 22:45:58 +0200 |
commit | d627672ec4a10861a659bfaacfaf86aa4b5b4e6e (patch) | |
tree | fd8e9af80295bac892e9e684ef4945d9761a3352 /test/files/neg | |
parent | 8aae23ed47c4e38a465ff3373392484ca82473d1 (diff) | |
download | scala-d627672ec4a10861a659bfaacfaf86aa4b5b4e6e.tar.gz scala-d627672ec4a10861a659bfaacfaf86aa4b5b4e6e.tar.bz2 scala-d627672ec4a10861a659bfaacfaf86aa4b5b4e6e.zip |
clearly establishes what macro bundles are
Previously it was enough to just extend scala.reflect.macros.Macro, which
created some loopholes, but now scalac enforces that bundles:
1) Are static (not necessarily top-level, but just static)
2) Are traits (objects shouldn't be bundles anyway, and classes bring
complications with their ctors which require special treatment in
generated classes, so why support them if they don't bring anything
new to the table?)
3) Are monomorphic (again, this brings unnecessary complications wrt
auxiliary code generation, so I don't see merit in supporting
polymorphic bundles, whatever that a polymorphic bundle could mean)
4) Don't provide concrete implementation for Macro.c (if they do then
what is the point?)
Diffstat (limited to 'test/files/neg')
-rw-r--r-- | test/files/neg/macro-bundle-abstract.check | 4 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-abstract.scala | 12 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-class.check | 4 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-class.scala | 11 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-nonmacro.check | 4 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-nonmacro.scala | 9 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-object.check | 7 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-object.scala | 12 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-polymorphic.check | 10 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-polymorphic.scala | 13 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-trait.check | 4 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-trait.scala | 12 |
12 files changed, 102 insertions, 0 deletions
diff --git a/test/files/neg/macro-bundle-abstract.check b/test/files/neg/macro-bundle-abstract.check new file mode 100644 index 0000000000..4b07adcc95 --- /dev/null +++ b/test/files/neg/macro-bundle-abstract.check @@ -0,0 +1,4 @@ +macro-bundle-abstract.scala:5: error: class Bundle$Bundle needs to be abstract, since method deferred in trait Bundle of type => Int is not defined +trait Bundle extends Macro { + ^ +one error found diff --git a/test/files/neg/macro-bundle-abstract.scala b/test/files/neg/macro-bundle-abstract.scala new file mode 100644 index 0000000000..2b302045da --- /dev/null +++ b/test/files/neg/macro-bundle-abstract.scala @@ -0,0 +1,12 @@ +import scala.language.experimental.macros +import scala.reflect.macros.Macro +import scala.reflect.macros.Context + +trait Bundle extends Macro { + def deferred: Int + def impl = ??? +} + +object Macros { + def foo = macro Bundle.impl +}
\ No newline at end of file diff --git a/test/files/neg/macro-bundle-class.check b/test/files/neg/macro-bundle-class.check new file mode 100644 index 0000000000..92695390ab --- /dev/null +++ b/test/files/neg/macro-bundle-class.check @@ -0,0 +1,4 @@ +macro-bundle-class.scala:10: error: macro bundles must be monomorphic traits extending scala.reflect.macros.Macro and not implementing its `val c: Context` member + def foo = macro Bundle.impl + ^ +one error found diff --git a/test/files/neg/macro-bundle-class.scala b/test/files/neg/macro-bundle-class.scala new file mode 100644 index 0000000000..4b92cdd40f --- /dev/null +++ b/test/files/neg/macro-bundle-class.scala @@ -0,0 +1,11 @@ +import scala.language.experimental.macros +import scala.reflect.macros.Macro +import scala.reflect.macros.Context + +class Bundle(val c: Context) extends Macro { + def impl = ??? +} + +object Macros { + def foo = macro Bundle.impl +}
\ No newline at end of file diff --git a/test/files/neg/macro-bundle-nonmacro.check b/test/files/neg/macro-bundle-nonmacro.check new file mode 100644 index 0000000000..5a265b5724 --- /dev/null +++ b/test/files/neg/macro-bundle-nonmacro.check @@ -0,0 +1,4 @@ +macro-bundle-nonmacro.scala:8: error: not found: value Bundle + def foo = Bundle.impl + ^ +one error found diff --git a/test/files/neg/macro-bundle-nonmacro.scala b/test/files/neg/macro-bundle-nonmacro.scala new file mode 100644 index 0000000000..c7d99f4582 --- /dev/null +++ b/test/files/neg/macro-bundle-nonmacro.scala @@ -0,0 +1,9 @@ +import scala.language.experimental.macros + +trait Bundle { + def impl = ??? +} + +object Macros { + def foo = Bundle.impl +}
\ No newline at end of file diff --git a/test/files/neg/macro-bundle-object.check b/test/files/neg/macro-bundle-object.check new file mode 100644 index 0000000000..e122001427 --- /dev/null +++ b/test/files/neg/macro-bundle-object.check @@ -0,0 +1,7 @@ +macro-bundle-object.scala:11: error: macro implementation has wrong shape: + required: (c: scala.reflect.macros.Context): c.Expr[Any] + found : : Nothing +number of parameter sections differ + def foo = macro Bundle.impl + ^ +one error found diff --git a/test/files/neg/macro-bundle-object.scala b/test/files/neg/macro-bundle-object.scala new file mode 100644 index 0000000000..98c4238a62 --- /dev/null +++ b/test/files/neg/macro-bundle-object.scala @@ -0,0 +1,12 @@ +import scala.language.experimental.macros +import scala.reflect.macros.Macro +import scala.reflect.macros.Context + +object Bundle extends Macro { + val c: Context = ??? + def impl = ??? +} + +object Macros { + def foo = macro Bundle.impl +}
\ No newline at end of file diff --git a/test/files/neg/macro-bundle-polymorphic.check b/test/files/neg/macro-bundle-polymorphic.check new file mode 100644 index 0000000000..204bd30bca --- /dev/null +++ b/test/files/neg/macro-bundle-polymorphic.check @@ -0,0 +1,10 @@ +macro-bundle-polymorphic.scala:10: error: macro bundles must be monomorphic traits extending scala.reflect.macros.Macro and not implementing its `val c: Context` member + def foo = macro Bundle.impl + ^ +macro-bundle-polymorphic.scala:11: error: macro bundles must be monomorphic traits extending scala.reflect.macros.Macro and not implementing its `val c: Context` member + def foo = macro Bundle[Int].impl + ^ +macro-bundle-polymorphic.scala:12: error: macro bundles must be monomorphic traits extending scala.reflect.macros.Macro and not implementing its `val c: Context` member + def foo = macro Bundle[Int, Nothing].impl + ^ +three errors found diff --git a/test/files/neg/macro-bundle-polymorphic.scala b/test/files/neg/macro-bundle-polymorphic.scala new file mode 100644 index 0000000000..0468d841bd --- /dev/null +++ b/test/files/neg/macro-bundle-polymorphic.scala @@ -0,0 +1,13 @@ +import scala.language.experimental.macros +import scala.reflect.macros.Macro +import scala.reflect.macros.Context + +trait Bundle[T] extends Macro { + def impl = ??? +} + +object Macros { + def foo = macro Bundle.impl + def foo = macro Bundle[Int].impl + def foo = macro Bundle[Int, Nothing].impl +}
\ No newline at end of file diff --git a/test/files/neg/macro-bundle-trait.check b/test/files/neg/macro-bundle-trait.check new file mode 100644 index 0000000000..972788c577 --- /dev/null +++ b/test/files/neg/macro-bundle-trait.check @@ -0,0 +1,4 @@ +macro-bundle-trait.scala:11: error: macro bundles must be monomorphic traits extending scala.reflect.macros.Macro and not implementing its `val c: Context` member + def foo = macro Bundle.impl + ^ +one error found diff --git a/test/files/neg/macro-bundle-trait.scala b/test/files/neg/macro-bundle-trait.scala new file mode 100644 index 0000000000..ddc87f6db3 --- /dev/null +++ b/test/files/neg/macro-bundle-trait.scala @@ -0,0 +1,12 @@ +import scala.language.experimental.macros +import scala.reflect.macros.Macro +import scala.reflect.macros.Context + +trait Bundle extends Macro { + val c: Context = ??? + def impl = ??? +} + +object Macros { + def foo = macro Bundle.impl +}
\ No newline at end of file |