diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-10-23 16:26:46 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-10-27 22:34:33 +1000 |
commit | 337b52b298be95df0b4b9a4bacb7c4b802620cf6 (patch) | |
tree | b9e211946e905a455082bf56dbd8095a5515b7ff /test/files/presentation/quasiquotes.flags | |
parent | 850899b1c9347e804763a258f64d54cef0ffd69a (diff) | |
download | scala-337b52b298be95df0b4b9a4bacb7c4b802620cf6.tar.gz scala-337b52b298be95df0b4b9a4bacb7c4b802620cf6.tar.bz2 scala-337b52b298be95df0b4b9a4bacb7c4b802620cf6.zip |
SI-8934 Fix whitebox extractor macros in the pres. compiler
The code that "aligns" patterns and extractors assumes that it can
look at the type of the unapply method to figure the arity of the
extractor.
However, the result type of a whitebox macro does not tell the
whole story, only after expanding an application of that macro do
we know the result type.
During regular compilation, this isn't a problem, as the macro
application is expanded to a call to a synthetic unapply:
{
class anon$1 {
def unapply(tree: Any): Option[(Tree, List[Treed])]
}
new anon$1
}.unapply(<unapply selector>)
In the presentation compiler, however, we now use
`-Ymacro-expand:discard`, which expands macros only to compute
the type of the application (and to allow the macro to issue
warnings/errors). The original application is retained in the
typechecked tree, modified only by attributing the potentially-sharper
type taken from the expanded macro.
This was done to improve hyperlinking support in the IDE.
This commit passes `sel.tpe` (which is the type computed by the
macro expansion) to `unapplyMethodTypes`, rather than using
the `finalResultType` of the unapply method.
This is tested with a presentation compiler test (which closely
mimics the reported bug), and with a pos test that also exercises
`-Ymacro-expand:discard`. Prior to this patch, they used to fail with:
too many patterns for trait api: expected 1, found 2
Diffstat (limited to 'test/files/presentation/quasiquotes.flags')
-rw-r--r-- | test/files/presentation/quasiquotes.flags | 0 |
1 files changed, 0 insertions, 0 deletions
diff --git a/test/files/presentation/quasiquotes.flags b/test/files/presentation/quasiquotes.flags new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/presentation/quasiquotes.flags |