summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/ast/TreeGen.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-08-05 17:29:28 +0000
committerPaul Phillips <paulp@improving.org>2011-08-05 17:29:28 +0000
commitf7f5b50848c8c0efd30abe17467d1ef443760ec5 (patch)
tree6ea288d5af2492fce0420b669262cfe50831e13f /src/compiler/scala/tools/nsc/ast/TreeGen.scala
parent234336d7b1ca19ae496a616012733a7a98462e4b (diff)
downloadscala-f7f5b50848c8c0efd30abe17467d1ef443760ec5.tar.gz
scala-f7f5b50848c8c0efd30abe17467d1ef443760ec5.tar.bz2
scala-f7f5b50848c8c0efd30abe17467d1ef443760ec5.zip
Rewrote the case class synthetic equals method ...
Rewrote the case class synthetic equals method to be more efficient and to cause fewer problems for compiler hackers who are always saying stuff like "the only place this comes up is case class equals..." No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/TreeGen.scala')
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeGen.scala15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
index 10762bfa98..acca7dac7d 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
@@ -32,7 +32,20 @@ abstract class TreeGen extends reflect.internal.TreeGen {
}
// wrap the given expression in a SoftReference so it can be gc-ed
- def mkSoftRef(expr: Tree): Tree = New(TypeTree(SoftReferenceClass.tpe), List(List(expr)))
+ def mkSoftRef(expr: Tree): Tree = atPos(expr.pos) {
+ New(SoftReferenceClass, expr)
+ }
+ // annotate the expression with @unchecked
+ def mkUnchecked(expr: Tree): Tree = atPos(expr.pos) {
+ // This can't be "Annotated(New(UncheckedClass), expr)" because annotations
+ // are very pick about things and it crashes the compiler with "unexpected new".
+ Annotated(New(scalaDot(UncheckedClass.name), List(Nil)), expr)
+ }
+ // if it's a Match, mark the selector unchecked; otherwise nothing.
+ def mkUncheckedMatch(tree: Tree) = tree match {
+ case Match(selector, cases) => atPos(tree.pos)(Match(mkUnchecked(selector), cases))
+ case _ => tree
+ }
def mkCached(cvar: Symbol, expr: Tree): Tree = {
val cvarRef = mkUnattributedRef(cvar)