summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAntonio Cunei <antonio.cunei@epfl.ch>2009-11-09 20:34:09 +0000
committerAntonio Cunei <antonio.cunei@epfl.ch>2009-11-09 20:34:09 +0000
commit29d431ce89db67e079943eeaff322c60410cd713 (patch)
tree5a50d5cf201fc852af16b5edf59b9c7ddf7b2c8c /src
parentcedd41ba4a14f7f1595057edfeca5437ef674bc3 (diff)
downloadscala-29d431ce89db67e079943eeaff322c60410cd713.tar.gz
scala-29d431ce89db67e079943eeaff322c60410cd713.tar.bz2
scala-29d431ce89db67e079943eeaff322c60410cd713.zip
Reverted r19466, as the decision is now that
isDefinedAt should /not/ be in Function1
Diffstat (limited to 'src')
-rw-r--r--src/actors/scala/actors/Actor.scala2
-rw-r--r--src/actors/scala/actors/Future.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala19
-rw-r--r--src/library/scala/Function1.scala6
-rw-r--r--src/library/scala/PartialFunction.scala11
-rw-r--r--src/library/scala/collection/MapLike.scala2
-rw-r--r--src/library/scala/collection/SeqLike.scala4
-rw-r--r--src/library/scala/util/control/Exception.scala8
-rw-r--r--src/swing/scala/swing/Reactions.scala4
9 files changed, 26 insertions, 32 deletions
diff --git a/src/actors/scala/actors/Actor.scala b/src/actors/scala/actors/Actor.scala
index 69a4aab7d7..b563104f41 100644
--- a/src/actors/scala/actors/Actor.scala
+++ b/src/actors/scala/actors/Actor.scala
@@ -210,7 +210,7 @@ object Actor {
private class RecursiveProxyHandler(a: Reactor, f: PartialFunction[Any, Unit])
extends PartialFunction[Any, Unit] {
- override def isDefinedAt(m: Any): Boolean =
+ def isDefinedAt(m: Any): Boolean =
true // events are immediately removed from the mailbox
def apply(m: Any) {
if (f.isDefinedAt(m)) f(m)
diff --git a/src/actors/scala/actors/Future.scala b/src/actors/scala/actors/Future.scala
index 63007b6477..38b268d795 100644
--- a/src/actors/scala/actors/Future.scala
+++ b/src/actors/scala/actors/Future.scala
@@ -105,7 +105,7 @@ object Futures {
def awaitWith(partFuns: Seq[PartialFunction[Any, Pair[Int, Any]]]) {
val reaction: PartialFunction[Any, Unit] = new PartialFunction[Any, Unit] {
- override def isDefinedAt(msg: Any) = msg match {
+ def isDefinedAt(msg: Any) = msg match {
case TIMEOUT => true
case _ => partFuns exists (_ isDefinedAt msg)
}
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index 36ca4f399d..eec523a2b8 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -282,7 +282,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
* class $anon() extends Object() with PartialFunction[T, R] with ScalaObject {
* def apply(x: T): R = (x: @unchecked) match {
* { case P_i if G_i => E_i }_i=1..n
- * override def isDefinedAt(x: T): boolean = (x: @unchecked) match {
+ * def isDefinedAt(x: T): boolean = (x: @unchecked) match {
* case P_1 if G_1 => true
* ...
* case P_n if G_n => true
@@ -291,12 +291,9 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
* }
* new $anon()
*
- * However, if one of the patterns P_i if G_i is a default pattern, it should generate instead
+ * However, if one of the patterns P_i if G_i is a default pattern, generate instead
*
- * override def isDefinedAt(x: T): boolean = true
- *
- * which is the default in Function1 (and PartialFunction) anyway, so
- * no overridden def is emitted.
+ * def isDefinedAt(x: T): boolean = true
*/
def transformFunction(fun: Function): Tree = {
val fun1 = deEta(fun)
@@ -338,7 +335,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
}
val members = {
if (fun.tpe.typeSymbol == PartialFunctionClass) {
- val isDefinedAtMethod = anonClass.newMethod(fun.pos, nme.isDefinedAt).setFlag(FINAL | OVERRIDE)
+ val isDefinedAtMethod = anonClass.newMethod(fun.pos, nme.isDefinedAt).setFlag(FINAL)
isDefinedAtMethod.setInfo(MethodType(isDefinedAtMethod.newSyntheticValueParams(formals),
BooleanClass.tpe))
anonClass.info.decls enter isDefinedAtMethod
@@ -356,12 +353,8 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
(cases map transformCase) :::
List(CaseDef(Ident(nme.WILDCARD), EmptyTree, Literal(false))))
}
- val isDef=idbody(isDefinedAtMethod.paramss.head.head)
- if (isDef == Literal(true))
- List(applyMethodDef(mkUnchecked(fun.body)))
- else
- List(applyMethodDef(mkUnchecked(fun.body)),
- DefDef(isDefinedAtMethod, mkUnchecked(isDef)))
+ List(applyMethodDef(mkUnchecked(fun.body)),
+ DefDef(isDefinedAtMethod, mkUnchecked(idbody(isDefinedAtMethod.paramss.head.head))))
} else {
List(applyMethodDef(fun.body))
}
diff --git a/src/library/scala/Function1.scala b/src/library/scala/Function1.scala
index 80fe7ad1b6..7cfd32304e 100644
--- a/src/library/scala/Function1.scala
+++ b/src/library/scala/Function1.scala
@@ -47,10 +47,4 @@ trait Function1[-T1, +R] extends AnyRef { self =>
*/
def andThen[A](g: R => A): T1 => A = { x => g(apply(x)) }
- /** Checks if a value is contained in the functions domain.
- *
- * @param x the value to test
- * @return true, iff <code>x</code> is in the domain of this function.
- */
- def isDefinedAt(x: T1): Boolean = true
}
diff --git a/src/library/scala/PartialFunction.scala b/src/library/scala/PartialFunction.scala
index 1eb5f89fa4..0ba7527976 100644
--- a/src/library/scala/PartialFunction.scala
+++ b/src/library/scala/PartialFunction.scala
@@ -21,9 +21,16 @@ package scala
*/
trait PartialFunction[-A, +B] extends AnyRef with (A => B) {
+ /** Checks if a value is contained in the functions domain.
+ *
+ * @param x the value to test
+ * @return true, iff <code>x</code> is in the domain of this function.
+ */
+ def isDefinedAt(x: A): Boolean
+
def orElse[A1 <: A, B1 >: B](that: PartialFunction[A1, B1]) : PartialFunction[A1, B1] =
new PartialFunction[A1, B1] {
- override def isDefinedAt(x: A1): Boolean =
+ def isDefinedAt(x: A1): Boolean =
PartialFunction.this.isDefinedAt(x) || that.isDefinedAt(x)
def apply(x: A1): B1 =
if (PartialFunction.this.isDefinedAt(x)) PartialFunction.this.apply(x)
@@ -31,7 +38,7 @@ trait PartialFunction[-A, +B] extends AnyRef with (A => B) {
}
override def andThen[C](k: B => C) : PartialFunction[A, C] = new PartialFunction[A, C] {
- override def isDefinedAt(x: A): Boolean = PartialFunction.this.isDefinedAt(x)
+ def isDefinedAt(x: A): Boolean = PartialFunction.this.isDefinedAt(x)
def apply(x: A): C = k(PartialFunction.this.apply(x))
}
}
diff --git a/src/library/scala/collection/MapLike.scala b/src/library/scala/collection/MapLike.scala
index 8c44c374ca..3b188acab6 100644
--- a/src/library/scala/collection/MapLike.scala
+++ b/src/library/scala/collection/MapLike.scala
@@ -122,7 +122,7 @@ self =>
* @param key the key
* @return <code>true</code> iff there is a mapping for key in this map
*/
- override def isDefinedAt(key: A) = contains(key)
+ def isDefinedAt(key: A) = contains(key)
/** @return the keys of this map as a set. */
def keySet: Set[A] = new DefaultKeySet
diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala
index 3413cb8a07..708764e958 100644
--- a/src/library/scala/collection/SeqLike.scala
+++ b/src/library/scala/collection/SeqLike.scala
@@ -109,7 +109,7 @@ object SeqLike {
* @version 1.0, 16/07/2003
* @since 2.8
*/
-trait SeqLike[+A, +Repr] extends Function[Int, A] with IterableLike[A, Repr] { self =>
+trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] { self =>
override protected[this] def thisCollection: Seq[A] = this.asInstanceOf[Seq[A]]
override protected[this] def toCollection(repr: Repr): Seq[A] = repr.asInstanceOf[Seq[A]]
@@ -147,7 +147,7 @@ trait SeqLike[+A, +Repr] extends Function[Int, A] with IterableLike[A, Repr] { s
/** Is this partial function defined for the index <code>x</code>?
*/
- override def isDefinedAt(x: Int): Boolean = (x >= 0) && (x < length)
+ def isDefinedAt(x: Int): Boolean = (x >= 0) && (x < length)
/** Returns length of longest segment starting from a start index `from`
* such that every element of the segment satisfies predicate `p`.
diff --git a/src/library/scala/util/control/Exception.scala b/src/library/scala/util/control/Exception.scala
index 8add16fb70..356b11df51 100644
--- a/src/library/scala/util/control/Exception.scala
+++ b/src/library/scala/util/control/Exception.scala
@@ -31,7 +31,7 @@ object Exception
// a Throwable => T and simply rethrow the non-Exceptions.
implicit def fromExceptionCatcher[T](pf: ExceptionCatcher[T]): Catcher[T] = {
new PartialFunction[Throwable, T] {
- override def isDefinedAt(x: Throwable) = x match {
+ def isDefinedAt(x: Throwable) = x match {
case e: Exception if pf.isDefinedAt(e) => true
case _ => false
}
@@ -102,7 +102,7 @@ object Exception
* but with the supplied apply method replacing the current one. */
def withApply[U](f: (Throwable) => U): Catch[U] = {
val pf2 = new PartialFunction[Throwable, U] {
- override def isDefinedAt(x: Throwable) = pf isDefinedAt x
+ def isDefinedAt(x: Throwable) = pf isDefinedAt x
def apply(x: Throwable) = f(x)
}
new Catch(pf2, fin)
@@ -141,7 +141,7 @@ object Exception
final val nothingCatcher: PartialFunction[Throwable, Nothing] =
new PartialFunction[Throwable, Nothing] {
- override def isDefinedAt(x: Throwable) = false
+ def isDefinedAt(x: Throwable) = false
def apply(x: Throwable) = throw x
}
@@ -209,6 +209,6 @@ object Exception
private def pfFromExceptions(exceptions: Class[_]*) =
new PartialFunction[Throwable, Nothing] {
def apply(x: Throwable) = throw x
- override def isDefinedAt(x: Throwable) = wouldMatch(x, exceptions)
+ def isDefinedAt(x: Throwable) = wouldMatch(x, exceptions)
}
}
diff --git a/src/swing/scala/swing/Reactions.scala b/src/swing/scala/swing/Reactions.scala
index fbb20ada9f..dc7cb2d2f1 100644
--- a/src/swing/scala/swing/Reactions.scala
+++ b/src/swing/scala/swing/Reactions.scala
@@ -19,7 +19,7 @@ object Reactions {
class Impl extends Reactions {
private val parts: Buffer[Reaction] = new ListBuffer[Reaction]
- override def isDefinedAt(e: Event) = parts.exists(_ isDefinedAt e)
+ def isDefinedAt(e: Event) = parts.exists(_ isDefinedAt e)
def += (r: Reaction): this.type = { parts += r; this }
def -= (r: Reaction): this.type = { parts -= r; this }
def apply(e: Event) {
@@ -36,7 +36,7 @@ object Reactions {
class Wrapper(listener: Any)(r: Reaction) extends Reaction with StronglyReferenced with Proxy {
def self = listener
- override def isDefinedAt(e: Event) = r.isDefinedAt(e)
+ def isDefinedAt(e: Event) = r.isDefinedAt(e)
def apply(e: Event) { r(e) }
}
}