diff options
author | Martin Odersky <odersky@gmail.com> | 2011-11-24 09:25:00 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2011-11-24 09:25:00 +0000 |
commit | 5fb26c6a889cf1609823338df8783bf880769b3f (patch) | |
tree | 652d5c036465b669dc09039392ce79ab8f4b7759 /src/compiler | |
parent | 32a753546e0f7ef30e3e9c08b39a503ea93bc95a (diff) | |
download | scala-5fb26c6a889cf1609823338df8783bf880769b3f.tar.gz scala-5fb26c6a889cf1609823338df8783bf880769b3f.tar.bz2 scala-5fb26c6a889cf1609823338df8783bf880769b3f.zip |
Fast PartialFunction # orElse.
Diffstat (limited to 'src/compiler')
4 files changed, 8 insertions, 7 deletions
diff --git a/src/compiler/scala/reflect/internal/Flags.scala b/src/compiler/scala/reflect/internal/Flags.scala index 209ca94e50..50d5b5cb82 100644 --- a/src/compiler/scala/reflect/internal/Flags.scala +++ b/src/compiler/scala/reflect/internal/Flags.scala @@ -96,6 +96,7 @@ class ModifierFlags { final val INTERFACE = 0x00000080 // symbol is an interface (i.e. a trait which defines only abstract methods) final val MUTABLE = 0x00001000 // symbol is a mutable variable. final val PARAM = 0x00002000 // symbol is a (value or type) parameter to a method + final val MACRO = 0x00008000 // symbol is a macro definition final val COVARIANT = 0x00010000 // symbol is a covariant type variable final val BYNAMEPARAM = 0x00010000 // parameter is by name diff --git a/src/compiler/scala/tools/cmd/FromString.scala b/src/compiler/scala/tools/cmd/FromString.scala index 992530c767..e4504702d4 100644 --- a/src/compiler/scala/tools/cmd/FromString.scala +++ b/src/compiler/scala/tools/cmd/FromString.scala @@ -16,7 +16,7 @@ import scala.reflect.OptManifest */ abstract class FromString[+T](implicit m: OptManifest[T]) extends scala.runtime.AbstractPartialFunction[String, T] { def apply(s: String): T - def isDefinedAt(s: String): Boolean = true + def _isDefinedAt(s: String): Boolean = true def zero: T = apply("") def targetString: String = m.toString @@ -30,20 +30,20 @@ object FromString { /** Path related stringifiers. */ val ExistingFile: FromString[File] = new FromString[File] { - override def isDefinedAt(s: String) = toFile(s).isFile + override def _isDefinedAt(s: String) = toFile(s).isFile def apply(s: String): File = if (isDefinedAt(s)) toFile(s) else cmd.runAndExit(println("'%s' is not an existing file." format s)) } val ExistingDir: FromString[Directory] = new FromString[Directory] { - override def isDefinedAt(s: String) = toDir(s).isDirectory + override def _isDefinedAt(s: String) = toDir(s).isDirectory def apply(s: String): Directory = if (isDefinedAt(s)) toDir(s) else cmd.runAndExit(println("'%s' is not an existing directory." format s)) } def ExistingDirRelativeTo(root: Directory) = new FromString[Directory] { private def resolve(s: String) = toDir(s) toAbsoluteWithRoot root toDirectory - override def isDefinedAt(s: String) = resolve(s).isDirectory + override def _isDefinedAt(s: String) = resolve(s).isDirectory def apply(s: String): Directory = if (isDefinedAt(s)) resolve(s) else cmd.runAndExit(println("'%s' is not an existing directory." format resolve(s))) @@ -65,7 +65,7 @@ object FromString { /** Implicit as the most likely to be useful as-is. */ implicit val IntFromString: FromString[Int] = new FromString[Int] { - override def isDefinedAt(s: String) = safeToInt(s).isDefined + override def _isDefinedAt(s: String) = safeToInt(s).isDefined def apply(s: String) = safeToInt(s).get def safeToInt(s: String): Option[Int] = try Some(java.lang.Integer.parseInt(s)) catch { case _: NumberFormatException => None } } diff --git a/src/compiler/scala/tools/nsc/interpreter/AbstractOrMissingHandler.scala b/src/compiler/scala/tools/nsc/interpreter/AbstractOrMissingHandler.scala index d21d67db6e..33ef4a432d 100644 --- a/src/compiler/scala/tools/nsc/interpreter/AbstractOrMissingHandler.scala +++ b/src/compiler/scala/tools/nsc/interpreter/AbstractOrMissingHandler.scala @@ -7,7 +7,7 @@ package scala.tools.nsc package interpreter class AbstractOrMissingHandler[T](onError: String => Unit, value: T) extends scala.runtime.AbstractPartialFunction[Throwable, T] { - def isDefinedAt(t: Throwable) = t match { + def _isDefinedAt(t: Throwable) = t match { case _: AbstractMethodError => true case _: NoSuchMethodError => true case _: MissingRequirementError => true diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala index 481a997c00..c97d65c6bc 100644 --- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala +++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala @@ -433,7 +433,7 @@ trait ParallelMatching extends ast.TreeDSL case (false, false) => pivotLen == x.nonStarLength } - def isDefinedAt(pat: Pattern) = pat match { + def _isDefinedAt(pat: Pattern) = pat match { case x: SequenceLikePattern => seqIsDefinedAt(x) case WildcardPattern() => true case _ => false |