Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10323 from som-snytt/issue/10589-case-implicit-param
Reification knows only first param list is case accessor
- Loading branch information
Showing
3 changed files
with
32 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// scalac: -Ymacro-annotations | ||
trait T[A] | ||
|
||
@macid | ||
case class CC[A: T](x: A) | ||
|
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,19 @@ | ||
// scalac: -Ymacro-annotations | ||
|
||
import scala.annotation.StaticAnnotation | ||
import scala.language.experimental.macros | ||
import scala.reflect.macros.whitebox.Context | ||
|
||
class macid extends StaticAnnotation { | ||
def macroTransform(annottees: Any*): Any = macro macidMacro.impl | ||
} | ||
object macidMacro { | ||
def impl(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = { | ||
new Macros[c.type](c).macidMacroImpl(annottees.toList) | ||
} | ||
} | ||
class Macros[C <: Context](val c: C) { | ||
import c.universe._ | ||
def macidMacroImpl(annottees: List[c.Expr[Any]]): c.Expr[Any] = | ||
annottees(0) | ||
} |