diff options
author | Paul Phillips <paulp@improving.org> | 2010-05-15 05:57:50 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-05-15 05:57:50 +0000 |
commit | f4420e7b13542f771c3ca80abfeab4dabf16b309 (patch) | |
tree | d680eb76f3232dcecea64580c6b614f0a0583c2e | |
parent | d97b3a8066dfe588e080c6b3c87bda2c9f27f80e (diff) | |
download | scala-f4420e7b13542f771c3ca80abfeab4dabf16b309.tar.gz scala-f4420e7b13542f771c3ca80abfeab4dabf16b309.tar.bz2 scala-f4420e7b13542f771c3ca80abfeab4dabf16b309.zip |
Swapped the order of the arguments to returning...
Swapped the order of the arguments to returning to make it consistent
with the way I've been using it for a long time. No review, how about
a question for nobody in particular instead: can we put this in the
library somewhere so I can stop looking around for it everywhere I go?
It's really handy.
def returning[T](x: T)(f: T => Unit): T = { f(x) ; x }
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/TreeDSL.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/MatrixAdditions.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Unapplies.scala | 12 |
3 files changed, 8 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala index 9aa36de703..38240316bb 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala @@ -26,7 +26,7 @@ trait TreeDSL { tree => IF (tree MEMBER_== NULL) THEN ifNull ELSE f(tree) // Applies a function to a value and then returns the value. - def returning[T](f: T => Unit)(x: T): T = { f(x) ; x } + def returning[T](x: T)(f: T => Unit): T = { f(x) ; x } // strip bindings to find what lies beneath final def unbind(x: Tree): Tree = x match { diff --git a/src/compiler/scala/tools/nsc/matching/MatrixAdditions.scala b/src/compiler/scala/tools/nsc/matching/MatrixAdditions.scala index d3dddbfaaf..fbfe00d2c1 100644 --- a/src/compiler/scala/tools/nsc/matching/MatrixAdditions.scala +++ b/src/compiler/scala/tools/nsc/matching/MatrixAdditions.scala @@ -135,7 +135,7 @@ trait MatrixAdditions extends ast.TreeDSL } } - returning[Tree](resetTraverser traverse _)(lxtt transform tree) + returning(lxtt transform tree)(resetTraverser traverse _) } } diff --git a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala index 2466f1e5d1..5bbda13acd 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala @@ -99,13 +99,13 @@ trait Unapplies extends ast.TreeDSL } def copyUntyped[T <: Tree](tree: T): T = - returning[T](UnTyper traverse _)(tree.duplicate) + returning[T](tree.duplicate)(UnTyper traverse _) - def copyUntypedInvariant(td: TypeDef): TypeDef = - returning[TypeDef](UnTyper traverse _)( - treeCopy.TypeDef(td, td.mods &~ (COVARIANT | CONTRAVARIANT), td.name, - td.tparams, td.rhs).duplicate - ) + def copyUntypedInvariant(td: TypeDef): TypeDef = { + val copy = treeCopy.TypeDef(td, td.mods &~ (COVARIANT | CONTRAVARIANT), td.name, td.tparams, td.rhs) + + returning[TypeDef](copy.duplicate)(UnTyper traverse _) + } private def classType(cdef: ClassDef, tparams: List[TypeDef]): Tree = { val tycon = REF(cdef.symbol) |