summaryrefslogtreecommitdiff
path: root/test/files/pos
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-12-31 15:46:47 +0100
committerEugene Burmako <xeno.by@gmail.com>2013-05-11 18:37:10 +0200
commit90ac5c4e1350493f6f47c674572c2dcb97b2b9eb (patch)
treedc944493949cdb17bf2aa032b62c117f29054fc1 /test/files/pos
parent0c6927b4845633f262794aadda9b188b140717b6 (diff)
downloadscala-90ac5c4e1350493f6f47c674572c2dcb97b2b9eb.tar.gz
scala-90ac5c4e1350493f6f47c674572c2dcb97b2b9eb.tar.bz2
scala-90ac5c4e1350493f6f47c674572c2dcb97b2b9eb.zip
[nomaster] SI-5923 instantiates targs in deferred macro applications
Amazingly enough, the fix for the "macro not expanded" problem was super easy. (And I remember spending a day or two trying to find a quick fix somewhen around Scala Days 2012!) The problem was in the implementation of the macro expansion trigger, which was buried in a chain of if-elif-elif in `adapt`. This meant that macro expansion was mutually exclusive with a lot of important adaptations, e.g. with `instantiate`. More precisely, if an expandee contains an undetparam, its expansion should be delayed until all its undetparams are inferred and then retried later. Sometimes such inference can only happen upon a call to instantiate in one of the elif's coming after the macro expansion elif. However this elif would never be called for expandees, because control flow would always enter the macro expansion branch preceding the inference branch. Therefore `macroExpand` now takes the matters in its own hands, calling `instantiate` if the expansion has been delayed and we're not in POLYmode (see a detailed explanation in a comment to `macroExpand`). Consequences of this fix are vast. First of all, we can get rid of the "type parameter must be specified" hack. Secondly and most importantly, we can now remove the `materializeImplicit` method from Implicits and rely on implicit macros to materialize tags for us. (This is a tricky change, and I'll do it later after we merge as much of my pending work as possible). Finally, we learn that the current scheme of interaction between macros, type inference and implicits is, in principle, sound! NOTE: This patch is a second take on fixing implicit macros, with the first one being a backport from macro paradise merged into master in January 2013: https://github.com/scala/scala/commit/fe60284769. The original fix had an unfortunate error, as described on scala-internals: https://groups.google.com/forum/#!msg/scala-internals/7pA9CiiD3u8, so I had to refine the approach here. This means that it's not possible to directly merge this commit into master, so I'm marking it as [nomaster] and will submit a separate pull request targetting master later on.
Diffstat (limited to 'test/files/pos')
-rw-r--r--test/files/pos/t5692a.check4
-rw-r--r--test/files/pos/t5692a.flags1
-rw-r--r--test/files/pos/t5692a/Macros_1.scala6
-rw-r--r--test/files/pos/t5692a/Test_2.scala3
-rw-r--r--test/files/pos/t5692b.check4
-rw-r--r--test/files/pos/t5692b.flags1
-rw-r--r--test/files/pos/t5692b/Macros_1.scala6
-rw-r--r--test/files/pos/t5692b/Test_2.scala3
8 files changed, 28 insertions, 0 deletions
diff --git a/test/files/pos/t5692a.check b/test/files/pos/t5692a.check
new file mode 100644
index 0000000000..7fbfb5dba7
--- /dev/null
+++ b/test/files/pos/t5692a.check
@@ -0,0 +1,4 @@
+Test_2.scala:2: error: this type parameter must be specified
+ def x = Macros.foo
+ ^
+one error found
diff --git a/test/files/pos/t5692a.flags b/test/files/pos/t5692a.flags
new file mode 100644
index 0000000000..cd66464f2f
--- /dev/null
+++ b/test/files/pos/t5692a.flags
@@ -0,0 +1 @@
+-language:experimental.macros \ No newline at end of file
diff --git a/test/files/pos/t5692a/Macros_1.scala b/test/files/pos/t5692a/Macros_1.scala
new file mode 100644
index 0000000000..06b5a3de36
--- /dev/null
+++ b/test/files/pos/t5692a/Macros_1.scala
@@ -0,0 +1,6 @@
+import scala.reflect.macros.Context
+
+object Macros {
+ def impl[T](c: Context) = c.literalUnit
+ def foo[T] = macro impl[T]
+} \ No newline at end of file
diff --git a/test/files/pos/t5692a/Test_2.scala b/test/files/pos/t5692a/Test_2.scala
new file mode 100644
index 0000000000..08d510cc6f
--- /dev/null
+++ b/test/files/pos/t5692a/Test_2.scala
@@ -0,0 +1,3 @@
+class Test {
+ def x = Macros.foo
+} \ No newline at end of file
diff --git a/test/files/pos/t5692b.check b/test/files/pos/t5692b.check
new file mode 100644
index 0000000000..16796826b4
--- /dev/null
+++ b/test/files/pos/t5692b.check
@@ -0,0 +1,4 @@
+Test_2.scala:2: error: these type parameters must be specified
+ def x = Macros.foo
+ ^
+one error found
diff --git a/test/files/pos/t5692b.flags b/test/files/pos/t5692b.flags
new file mode 100644
index 0000000000..cd66464f2f
--- /dev/null
+++ b/test/files/pos/t5692b.flags
@@ -0,0 +1 @@
+-language:experimental.macros \ No newline at end of file
diff --git a/test/files/pos/t5692b/Macros_1.scala b/test/files/pos/t5692b/Macros_1.scala
new file mode 100644
index 0000000000..b28d19f903
--- /dev/null
+++ b/test/files/pos/t5692b/Macros_1.scala
@@ -0,0 +1,6 @@
+import scala.reflect.macros.Context
+
+object Macros {
+ def impl[T, U](c: Context) = c.literalUnit
+ def foo[T, U] = macro impl[T, U]
+} \ No newline at end of file
diff --git a/test/files/pos/t5692b/Test_2.scala b/test/files/pos/t5692b/Test_2.scala
new file mode 100644
index 0000000000..08d510cc6f
--- /dev/null
+++ b/test/files/pos/t5692b/Test_2.scala
@@ -0,0 +1,3 @@
+class Test {
+ def x = Macros.foo
+} \ No newline at end of file