-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
transformers no longer ignore UnApply.fun
Second time's the charm. I remember trying to do exactly the same somewhen around 2.10.0-M4, but then some continuations tests were failing. Luckily, today everything went smoothly. Please note that this fix changes the way that SI-5465 manifests itself. Previously it produced type errors, now it simply crashes the compiler. Therefore I had to attach the try/catch FatalError clause to invocations of toolbox methods, so that compiler crashes get caught and translated to ToolBoxErrors. Also fixes SI-7871, and that clears the way for implementing quasiquotes with conventional macros rather than relying on a special case in typer.
- Loading branch information
Showing
5 changed files
with
71 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(SomeTree,SomeTree) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import scala.reflect.macros.Context | ||
import language.experimental.macros | ||
|
||
trait Tree | ||
case object SomeTree extends Tree | ||
|
||
object NewQuasiquotes { | ||
implicit class QuasiquoteInterpolation(c: StringContext) { | ||
object nq { | ||
def unapply(t: Tree) = macro QuasiquoteMacros.unapplyImpl | ||
} | ||
} | ||
} | ||
|
||
object QuasiquoteMacros { | ||
def unapplyImpl(c: Context)(t: c.Tree) = { | ||
import c.universe._ | ||
q""" | ||
new { | ||
def unapply(t: Tree) = t match { | ||
case SomeTree => Some((SomeTree, SomeTree)) | ||
case _ => None | ||
} | ||
}.unapply($t) | ||
""" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
object Test extends App { | ||
import NewQuasiquotes._ | ||
SomeTree match { | ||
case nq"$x + $y" => println((x, y)) | ||
} | ||
} |