diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2013-12-27 18:43:56 +0300 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2013-12-27 18:45:10 +0300 |
commit | bbd03b26f1eeba5abf495f5e745c6623f0cc05b7 (patch) | |
tree | d988476af3851a7e682f853c4058fe77e4fb4564 /src/compiler | |
parent | 9f0594c57716ed551918e15be6da843982e8ba12 (diff) | |
download | scala-bbd03b26f1eeba5abf495f5e745c6623f0cc05b7.tar.gz scala-bbd03b26f1eeba5abf495f5e745c6623f0cc05b7.tar.bz2 scala-bbd03b26f1eeba5abf495f5e745c6623f0cc05b7.zip |
SI-7777 applyDynamic macro fails for nested application
Interplay between the insertApply desugaring and the invokeDynamic desugarings
is already quite brittle, but the real fun begins when macros crash the party.
The proposed patch enriches the `isDesugaredApply` check performed in
`mkInvoke`, the invokeDynamic desugarer, and makes sure that everything
is safe and sound in the macroland.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala | 4 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 9 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala b/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala index 54c665fe56..86bf846f1c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala +++ b/src/compiler/scala/tools/nsc/typechecker/StdAttachments.scala @@ -50,6 +50,10 @@ trait StdAttachments { case _ => false } + /** Returns the original tree of the macro expansion if the argument is a macro expansion or EmptyTree otherwise. + */ + def macroExpandee(tree: Tree): Tree = tree.attachments.get[MacroExpansionAttachment].map(_.expandee).getOrElse(EmptyTree) + /** After macro expansion is completed, links the expandee and the expansion result by annotating them both with a `MacroExpansionAttachment`. * The `expanded` parameter is of type `Any`, because macros can expand both into trees and into annotations. */ diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 5e89440bc0..7ff9e854b1 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3953,9 +3953,12 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper def mkInvoke(cxTree: Tree, tree: Tree, qual: Tree, name: Name): Option[Tree] = { debuglog(s"dyna.mkInvoke($cxTree, $tree, $qual, $name)") val treeInfo.Applied(treeSelection, _, _) = tree - def isDesugaredApply = treeSelection match { - case Select(`qual`, nme.apply) => true - case _ => false + def isDesugaredApply = { + val protoQual = macroExpandee(qual) orElse qual + treeSelection match { + case Select(`protoQual`, nme.apply) => true + case _ => false + } } acceptsApplyDynamicWithType(qual, name) map { tp => // If tp == NoType, pass only explicit type arguments to applyXXX. Not used at all |