From c71cd0ef9a7e455e3a13526c2893d98b14582bbb Mon Sep 17 00:00:00 2001 From: Antonio Cunei Date: Thu, 12 Nov 2009 15:15:28 +0000 Subject: Merged revisions 19557,19561 via svnmerge from https://lampsvn.epfl.ch/svn-repos/scala/scala/trunk ........ r19557 | extempore | 2009-11-12 14:59:56 +0100 (Thu, 12 Nov 2009) | 1 line Removed some duplicated functions. ........ r19561 | rytz | 2009-11-12 15:57:15 +0100 (Thu, 12 Nov 2009) | 1 line avoid illegal forward references by moving synthetics to the beginning of the statement-list. fixes #2489 ........ --- src/compiler/scala/tools/nsc/ast/TreeDSL.scala | 13 +------------ src/compiler/scala/tools/nsc/matching/MatrixAdditions.scala | 1 + .../scala/tools/nsc/matching/ParallelMatching.scala | 1 + src/compiler/scala/tools/nsc/matching/PatternBindings.scala | 1 + src/compiler/scala/tools/nsc/matching/Patterns.scala | 1 + src/compiler/scala/tools/nsc/matching/TransMatcher.scala | 1 + src/compiler/scala/tools/nsc/typechecker/Typers.scala | 2 +- 7 files changed, 7 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala index c5cef0dd32..569b0f7b37 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala @@ -18,24 +18,13 @@ trait TreeDSL { import global._ import definitions._ import gen.{ scalaDot } + import PartialFunction._ object CODE { // Add a null check to a Tree => Tree function def nullSafe[T](f: Tree => Tree, ifNull: Tree): Tree => Tree = tree => IF (tree MEMBER_== NULL) THEN ifNull ELSE f(tree) - // XXX these two are in scala.PartialFunction now, just have to - // settle on the final names. - - // Create a conditional based on a partial function - for values not defined - // on the partial, it is false. - def cond[T](x: T)(f: PartialFunction[T, Boolean]) = (f isDefinedAt x) && f(x) - - // Like cond, but transforms the value T => Some(U) if the pf is defined, - // or returns None if it is not. - def condOpt[T,U](x: T)(f: PartialFunction[T, U]): Option[U] = - if (f isDefinedAt x) Some(f(x)) else None - // Applies a function to a value and then returns the value. def returning[T](f: T => Unit)(x: T): T = { f(x) ; x } diff --git a/src/compiler/scala/tools/nsc/matching/MatrixAdditions.scala b/src/compiler/scala/tools/nsc/matching/MatrixAdditions.scala index 37ddbbc671..ea8a8e5ce5 100644 --- a/src/compiler/scala/tools/nsc/matching/MatrixAdditions.scala +++ b/src/compiler/scala/tools/nsc/matching/MatrixAdditions.scala @@ -7,6 +7,7 @@ package scala.tools.nsc package matching import transform.ExplicitOuter +import PartialFunction._ /** Traits which are mixed into MatchMatrix, but separated out as * (somewhat) independent components to keep them on the sidelines. diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala index 4bc8826908..d87eb29cf1 100644 --- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala +++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala @@ -31,6 +31,7 @@ trait ParallelMatching extends ast.TreeDSL import Types._ import Debug._ import Flags.{ TRANS_FLAG } + import PartialFunction._ /** Transition **/ def toPats(xs: List[Tree]): List[Pattern] = xs map Pattern.apply diff --git a/src/compiler/scala/tools/nsc/matching/PatternBindings.scala b/src/compiler/scala/tools/nsc/matching/PatternBindings.scala index b4689ebc30..daaa7d8b88 100644 --- a/src/compiler/scala/tools/nsc/matching/PatternBindings.scala +++ b/src/compiler/scala/tools/nsc/matching/PatternBindings.scala @@ -8,6 +8,7 @@ package matching import transform.ExplicitOuter import collection.immutable.TreeMap +import PartialFunction._ trait PatternBindings extends ast.TreeDSL { diff --git a/src/compiler/scala/tools/nsc/matching/Patterns.scala b/src/compiler/scala/tools/nsc/matching/Patterns.scala index 8a596f1257..f1efd7436f 100644 --- a/src/compiler/scala/tools/nsc/matching/Patterns.scala +++ b/src/compiler/scala/tools/nsc/matching/Patterns.scala @@ -9,6 +9,7 @@ package matching import symtab.Flags import util.NoPosition import scala.util.NameTransformer.decode +import PartialFunction._ /** Patterns are wrappers for Trees with enhanced semantics. * diff --git a/src/compiler/scala/tools/nsc/matching/TransMatcher.scala b/src/compiler/scala/tools/nsc/matching/TransMatcher.scala index b47ebccfa9..ea29f1859b 100644 --- a/src/compiler/scala/tools/nsc/matching/TransMatcher.scala +++ b/src/compiler/scala/tools/nsc/matching/TransMatcher.scala @@ -13,6 +13,7 @@ import symtab.SymbolTable import transform.ExplicitOuter import java.io.{ StringWriter, PrintWriter } import scala.util.NameTransformer.decode +import PartialFunction._ /** Translation of pattern matching * diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 50627268c8..a7fd4f3a50 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2054,7 +2054,7 @@ trait Typers { self: Analyzer => moreToAdd = initSize != scope.size } if (newStats.isEmpty) stats - else stats ::: newStats.toList + else newStats.toList ::: stats } val result = stats mapConserve (typedStat) if (phase.erasedTypes) result -- cgit v1.2.3