scala/scala — pull request #3916 by retronym (2014-08-06 00:07:33+00:00)
Title: SI-8781 Avoid double-expansion under -Ymacro-expand:discard

This mode of macro expansion is used by the presentation compiler to
leave the original macro applications ("expandees") in the type
checked trees, annotated with the types of the expansions.

However, under some circumstances involving implicits, we would
re-expand the macro. If the macro wasn't stable, this could lead
to a type mismatch.

The originally reported problem was with the shapeless
`mkSingletonOps` macro. Its expansion had the type of a freshly-named
class local to the expansion. Upon the re-expansion, a new class
was generated, which lead to errors like:

client/Client.scala:4: error: type mismatch;
found : fresh$macro$2
required: fresh$macro$1

This commit suppressed re-expansion of the expandee by use of
the existing, tree attachment driven mechanism.

Review by @xeno-by. /cc @dragos