diff options
8 files changed, 10 insertions, 13 deletions
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 diff --git a/test/files/run/names-defaults.scala b/test/files/run/names-defaults.scala index d5524b95ab..0d4f3df42e 100644 --- a/test/files/run/names-defaults.scala +++ b/test/files/run/names-defaults.scala @@ -265,6 +265,9 @@ object Test extends Application { // #2390 case class A2390[T](x: Int) { def copy(a: Int)(b: Int = 0) = 0 } + // #2489 + class A2489 { def foo { def bar(a: Int = 1) = a; bar(); val u = 0 } } + // DEFINITIONS def test1(a: Int, b: String) = println(a +": "+ b) def test2(u: Int, v: Int)(k: String, l: Int) = println(l +": "+ k +", "+ (u + v)) |