summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/internal/Symbols.scala
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2013-12-09 18:25:43 +0100
committerEugene Burmako <xeno.by@gmail.com>2014-01-07 16:45:30 +0100
commit59cdd50fa8d2466b9778dca4b354afc03f17be67 (patch)
tree6c9bf58f51313fdbf3eceee7666a0af39fea50e6 /src/reflect/scala/reflect/internal/Symbols.scala
parent9f0594c57716ed551918e15be6da843982e8ba12 (diff)
downloadscala-59cdd50fa8d2466b9778dca4b354afc03f17be67.tar.gz
scala-59cdd50fa8d2466b9778dca4b354afc03f17be67.tar.bz2
scala-59cdd50fa8d2466b9778dca4b354afc03f17be67.zip
awakens default getter synthesis from the untyper nightmare
Our happy little macro paradise is regularly invaded by resetAllAttrs, the bane of all macros and typers. It’s so ruthless and devastating that we’ve been long scheming to hack something really cool and to one day defeat it. Today we make the first step towards the happy future. Today we overthrow the UnTyper, resetAllAttrs’s elder brother that rules in the kingdoms of GetterLand and CaseClassia, and banish him from the land of getters. In the name of what’s good and meta, let’s band together and completely drive him away in a subsequent pull request! To put it in a nutshell, instead of using untyper on a DefDef to do default getter synthesis, the commit duplicates the DefDef and does resetLocalAttrs on it. As default getter synthesis proceeds with figuring out type and value parameters for the getter, then its tpt and finally its rhs, the commit destructures the duplicated DefDef and then assembles the default getter from the destructured parts instead of doing copyUntyped/copyUntypedInvariant on the original DefDef. I would say the test coverage is pretty good, as I had to figure out 3 or 4 test failures before I got to the stage when everything worked. Iirc it tests pretty exotic stuff like polymorphic default parameters in both second and third parameter lists, so it looks like we're pretty good in this department.
Diffstat (limited to 'src/reflect/scala/reflect/internal/Symbols.scala')
-rw-r--r--src/reflect/scala/reflect/internal/Symbols.scala5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala
index 0dfcf06874..e15b33e5d7 100644
--- a/src/reflect/scala/reflect/internal/Symbols.scala
+++ b/src/reflect/scala/reflect/internal/Symbols.scala
@@ -801,9 +801,14 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
isConstructor && !isPrimaryConstructor
/** Is this symbol a synthetic apply or unapply method in a companion object of a case class? */
+ // xeno-by: why this obscure use of the CASE flag? why not simply compare name with nme.apply and nme.unapply?
final def isCaseApplyOrUnapply =
isMethod && isCase && isSynthetic
+ /** Is this symbol a synthetic copy method in a case class? */
+ final def isCaseCopy =
+ isMethod && owner.isCase && isSynthetic && name == nme.copy
+
/** Is this symbol a trait which needs an implementation class? */
final def needsImplClass = (
isTrait