diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2014-02-13 02:34:14 +0100 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2014-02-13 04:06:06 +0100 |
commit | c85435d91e26b97e22470af74138b4e8d4c3ae41 (patch) | |
tree | 9f2d9e7b2dda559db2faadf4deb20aa07f2c858f /test/files | |
parent | 00067482917cbe7ac337550e1f565fea966c2d78 (diff) | |
download | scala-c85435d91e26b97e22470af74138b4e8d4c3ae41.tar.gz scala-c85435d91e26b97e22470af74138b4e8d4c3ae41.tar.bz2 scala-c85435d91e26b97e22470af74138b4e8d4c3ae41.zip |
SI-8270 unconfuses bundles and vanilla macros
This fixes a mistake in macro impl ref typechecking that used to have
an heuristic to figure out whether it looks at a bundle method ref or at
a vanilla object method ref. Under some circumstances the heuristic could
fail, and then the macro engine would reject perfectly good macro impls.
Now every macro impl ref is typechecked twice - once as a bundle method ref
and once as a vanilla object method ref. Results are then analyzed,
checked against ambiguities (which are now correctly reported instead
of incorrectly prioritizing towards bundles) and delivered to the macro
engine.
The only heuristic left in place is the one that's used to report errors.
If both bundle and vanilla typechecks fail, then if a bundle candidate
looks sufficiently similar to a bundle, a bundle typecheck error is reported
providing some common bundle definition hints.
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/neg/macro-bundle-ambiguous.check | 5 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-ambiguous.scala | 14 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-priority-bundle.check | 8 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-priority-bundle.scala | 14 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-priority-nonbundle.check | 8 | ||||
-rw-r--r-- | test/files/neg/macro-bundle-priority-nonbundle.scala | 14 | ||||
-rw-r--r-- | test/files/neg/macro-quasiquotes.check | 2 | ||||
-rw-r--r-- | test/files/pos/macro-bundle-disambiguate-bundle.check | 0 | ||||
-rw-r--r-- | test/files/pos/macro-bundle-disambiguate-bundle.scala | 14 | ||||
-rw-r--r-- | test/files/pos/macro-bundle-disambiguate-nonbundle.check | 0 | ||||
-rw-r--r-- | test/files/pos/macro-bundle-disambiguate-nonbundle.scala | 14 |
11 files changed, 92 insertions, 1 deletions
diff --git a/test/files/neg/macro-bundle-ambiguous.check b/test/files/neg/macro-bundle-ambiguous.check new file mode 100644 index 0000000000..8430496455 --- /dev/null +++ b/test/files/neg/macro-bundle-ambiguous.check @@ -0,0 +1,5 @@ +macro-bundle-ambiguous.scala:13: error: macro implementation reference is ambiguous: makes sense both as +a macro bundle method reference and a vanilla object method reference + def foo: Unit = macro Macros.impl + ^ +one error found diff --git a/test/files/neg/macro-bundle-ambiguous.scala b/test/files/neg/macro-bundle-ambiguous.scala new file mode 100644 index 0000000000..92c359d9a9 --- /dev/null +++ b/test/files/neg/macro-bundle-ambiguous.scala @@ -0,0 +1,14 @@ +import scala.reflect.macros.whitebox._ +import scala.language.experimental.macros + +class Macros(val c: Context) { + def impl = ??? +} + +object Macros { + def impl(c: Context) = ??? +} + +object Test extends App { + def foo: Unit = macro Macros.impl +}
\ No newline at end of file diff --git a/test/files/neg/macro-bundle-priority-bundle.check b/test/files/neg/macro-bundle-priority-bundle.check new file mode 100644 index 0000000000..c6cea72ba6 --- /dev/null +++ b/test/files/neg/macro-bundle-priority-bundle.check @@ -0,0 +1,8 @@ +macro-bundle-priority-bundle.scala:13: error: bundle implementation has incompatible shape: + required: : Macros.this.c.Expr[Unit] + or : : Macros.this.c.Tree + found : (x: Macros.this.c.Tree): Nothing +number of parameter sections differ + def foo: Unit = macro Macros.impl + ^ +one error found diff --git a/test/files/neg/macro-bundle-priority-bundle.scala b/test/files/neg/macro-bundle-priority-bundle.scala new file mode 100644 index 0000000000..ce831a7121 --- /dev/null +++ b/test/files/neg/macro-bundle-priority-bundle.scala @@ -0,0 +1,14 @@ +import scala.reflect.macros.whitebox._ +import scala.language.experimental.macros + +class Macros(val c: Context) { + def impl(x: c.Tree) = ??? +} + +object Macros { + def impl(c: Context)(x: c.Tree) = ??? +} + +object Test extends App { + def foo: Unit = macro Macros.impl +}
\ No newline at end of file diff --git a/test/files/neg/macro-bundle-priority-nonbundle.check b/test/files/neg/macro-bundle-priority-nonbundle.check new file mode 100644 index 0000000000..0d03b5074b --- /dev/null +++ b/test/files/neg/macro-bundle-priority-nonbundle.check @@ -0,0 +1,8 @@ +macro-bundle-priority-nonbundle.scala:13: error: macro implementation has incompatible shape: + required: (c: scala.reflect.macros.whitebox.Context): c.Expr[Unit] + or : (c: scala.reflect.macros.whitebox.Context): c.Tree + found : (c: scala.reflect.macros.whitebox.Context)(x: c.Tree): Nothing +number of parameter sections differ + def foo: Unit = macro Macros.impl + ^ +one error found diff --git a/test/files/neg/macro-bundle-priority-nonbundle.scala b/test/files/neg/macro-bundle-priority-nonbundle.scala new file mode 100644 index 0000000000..8dc00f6dd3 --- /dev/null +++ b/test/files/neg/macro-bundle-priority-nonbundle.scala @@ -0,0 +1,14 @@ +import scala.reflect.macros.whitebox._ +import scala.language.experimental.macros + +class Macros(val c: scala.reflect.api.Universe) { + def impl(x: c.Tree) = ??? +} + +object Macros { + def impl(c: Context)(x: c.Tree) = ??? +} + +object Test extends App { + def foo: Unit = macro Macros.impl +}
\ No newline at end of file diff --git a/test/files/neg/macro-quasiquotes.check b/test/files/neg/macro-quasiquotes.check index c690b61fe1..a985aee156 100644 --- a/test/files/neg/macro-quasiquotes.check +++ b/test/files/neg/macro-quasiquotes.check @@ -1,4 +1,4 @@ -Macros_1.scala:14: error: macro implementation has incompatible shape: +Macros_1.scala:14: error: bundle implementation has incompatible shape: 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 diff --git a/test/files/pos/macro-bundle-disambiguate-bundle.check b/test/files/pos/macro-bundle-disambiguate-bundle.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/pos/macro-bundle-disambiguate-bundle.check diff --git a/test/files/pos/macro-bundle-disambiguate-bundle.scala b/test/files/pos/macro-bundle-disambiguate-bundle.scala new file mode 100644 index 0000000000..04809317e1 --- /dev/null +++ b/test/files/pos/macro-bundle-disambiguate-bundle.scala @@ -0,0 +1,14 @@ +import scala.reflect.macros.whitebox._ +import scala.language.experimental.macros + +class Macros(val c: Context) { + def impl = ??? +} + +object Macros { + def impl(c: Context)(x: c.Tree) = ??? +} + +object Test extends App { + def foo: Unit = macro Macros.impl +}
\ No newline at end of file diff --git a/test/files/pos/macro-bundle-disambiguate-nonbundle.check b/test/files/pos/macro-bundle-disambiguate-nonbundle.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/pos/macro-bundle-disambiguate-nonbundle.check diff --git a/test/files/pos/macro-bundle-disambiguate-nonbundle.scala b/test/files/pos/macro-bundle-disambiguate-nonbundle.scala new file mode 100644 index 0000000000..cb66f28a0b --- /dev/null +++ b/test/files/pos/macro-bundle-disambiguate-nonbundle.scala @@ -0,0 +1,14 @@ +import scala.reflect.macros.whitebox._ +import scala.language.experimental.macros + +class Macros(val c: Context) { + def impl(x: c.Tree) = ??? +} + +object Macros { + def impl(c: Context) = ??? +} + +object Test extends App { + def foo: Unit = macro Macros.impl +}
\ No newline at end of file |