scala/scala — pull request #4076 by retronym (2014-10-24 05:14:37+00:00)
Title: 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()

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 makes an isolated change to take the type of the macro
application into account as the result type of the `MethodType`
used to calculate the extractor arity.

The enclosed test used to fail with:

too many patterns for trait api: expected 1, found 2

But now passes.