diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-12-31 15:46:47 +0100 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2013-05-11 18:37:10 +0200 |
commit | 90ac5c4e1350493f6f47c674572c2dcb97b2b9eb (patch) | |
tree | dc944493949cdb17bf2aa032b62c117f29054fc1 /test/files/pos/t5692a.check | |
parent | 0c6927b4845633f262794aadda9b188b140717b6 (diff) | |
download | scala-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/t5692a.check')
-rw-r--r-- | test/files/pos/t5692a.check | 4 |
1 files changed, 4 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 |