diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2013-07-08 20:40:08 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2013-07-08 21:20:28 +0200 |
commit | 17719231c615c06eb83f4109f53bfdd948a6fdb1 (patch) | |
tree | 5cf71d6938d46d37dfc0892fe9dd004eac9888e0 /src/compiler/scala/tools/nsc/typechecker/Typers.scala | |
parent | 7184fe0d3740ac8558067c18bdf449a65a8a26b9 (diff) | |
download | scala-17719231c615c06eb83f4109f53bfdd948a6fdb1.tar.gz scala-17719231c615c06eb83f4109f53bfdd948a6fdb1.tar.bz2 scala-17719231c615c06eb83f4109f53bfdd948a6fdb1.zip |
introduces unapply macros for internal use
Adds a macro hook into the unapply part of `doTypedApply`, provides
`macroExpandUnapply` in the macro engine and applies a couple of minor
refactorings along the way (renames the ugly `macroExpand1` into
oblivion, changes the ctor of `Fingerprint` to be private and upgrades
`MacroRole` from a string to a value class).
Unapply macros haven't been approved for inclusion in 2.11.0, however
they are necessary for pattern-matching quasiquotes. Therefore I'm only
allowing them to expand for QuasiquoteClass_api_unapply.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 353e8e4810..8b57c4659b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3385,8 +3385,9 @@ trait Typers extends Adaptations with Tags { if (!tree.isErrorTyped) setError(tree) else tree // @H change to setError(treeCopy.Apply(tree, fun, args)) - case otpe if mode.inPatternMode && unapplyMember(otpe).exists => - doTypedUnapply(tree, fun0, fun, args, mode, pt) + case ExtractorType(unapply) if mode.inPatternMode => + if (unapply == QuasiquoteClass_api_unapply) macroExpandUnapply(this, tree, fun, unapply, args, mode, pt) + else doTypedUnapply(tree, fun0, fun, args, mode, pt) case _ => if (treeInfo.isMacroApplication(tree)) duplErrorTree(MacroTooManyArgumentListsError(tree, fun.symbol)) |