diff options
author | Martin Odersky <odersky@gmail.com> | 2007-12-19 10:38:50 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2007-12-19 10:38:50 +0000 |
commit | 2ed9387915c9b813907c811ff889a056333d2ded (patch) | |
tree | dc577ecb63a6b6955bc75edddbac45a9b49f2685 /src/library | |
parent | e5d6f338deead8beb992d215ff57ea78c8c5b6f5 (diff) | |
download | scala-2ed9387915c9b813907c811ff889a056333d2ded.tar.gz scala-2ed9387915c9b813907c811ff889a056333d2ded.tar.bz2 scala-2ed9387915c9b813907c811ff889a056333d2ded.zip |
dual mode (generics or not) version of compiler...
dual mode (generics or not) version of compiler and libraries
Diffstat (limited to 'src/library')
49 files changed, 104 insertions, 104 deletions
diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala index 2ecc8fa119..6d3ac1aafe 100644 --- a/src/library/scala/Predef.scala +++ b/src/library/scala/Predef.scala @@ -21,7 +21,7 @@ object Predef { // classOf dummy ------------------------------------------------------ /** Return the runtime representation of a class type. */ - def classOf[T]: Class = null + def classOf[T]: Class[T] = null // aliases ------------------------------------------------------------ @@ -46,7 +46,7 @@ object Predef { type String = java.lang.String type StringBuilder = compat.StringBuilder - type Class = java.lang.Class + type Class[T] = java.lang.Class[T] type Runnable = java.lang.Runnable type Throwable = java.lang.Throwable diff --git a/src/library/scala/collection/jcl/ArrayList.scala b/src/library/scala/collection/jcl/ArrayList.scala index 166dcc7314..159f3d2875 100644 --- a/src/library/scala/collection/jcl/ArrayList.scala +++ b/src/library/scala/collection/jcl/ArrayList.scala @@ -14,6 +14,6 @@ package scala.collection.jcl; * * @author Sean McDirmid */ -class ArrayList[A](override val underlying : java.util.ArrayList) extends BufferWrapper[A] { - def this() = this(new java.util.ArrayList); +class ArrayList[A](override val underlying : java.util.ArrayList[A]) extends BufferWrapper[A] { + def this() = this(new java.util.ArrayList[A]); } diff --git a/src/library/scala/collection/jcl/BufferWrapper.scala b/src/library/scala/collection/jcl/BufferWrapper.scala index b1b388ed19..0472c15dea 100644 --- a/src/library/scala/collection/jcl/BufferWrapper.scala +++ b/src/library/scala/collection/jcl/BufferWrapper.scala @@ -15,7 +15,7 @@ package scala.collection.jcl; * @author Sean McDirmid */ trait BufferWrapper[A] extends Buffer[A] with CollectionWrapper[A] { - def underlying : java.util.List; + def underlying : java.util.List[A]; override def elements : BufferIterator[Int,A] = new IteratorWrapper(underlying.listIterator); override def remove(idx : Int) = underlying.remove(idx).asInstanceOf[A]; override def add(a : A) = underlying.add(a); @@ -40,7 +40,7 @@ trait BufferWrapper[A] extends Buffer[A] with CollectionWrapper[A] { } override def elements = super[BufferWrapper].elements; } - class IteratorWrapper(underlying : java.util.ListIterator) extends MutableIterator.Wrapper[A](underlying) with BufferIterator[Int,A] { + class IteratorWrapper(underlying : java.util.ListIterator[A]) extends MutableIterator.Wrapper[A](underlying) with BufferIterator[Int,A] { def add(a : A) = underlying.add(a); def set(a : A) = underlying.set(a); def hasPrevious = underlying.hasPrevious; diff --git a/src/library/scala/collection/jcl/CollectionWrapper.scala b/src/library/scala/collection/jcl/CollectionWrapper.scala index 690f7e3d94..ec6a22f325 100644 --- a/src/library/scala/collection/jcl/CollectionWrapper.scala +++ b/src/library/scala/collection/jcl/CollectionWrapper.scala @@ -18,13 +18,15 @@ trait CollectionWrapper[A] extends Collection[A] with IterableWrapper[A] { /** Override to specify the collection being accessed through this wrapper. ** Collection operations are then routed through the wrapped Java collection. **/ - def underlying : java.util.Collection; + def underlying : java.util.Collection[A]; override def has(a : A) = underlying.contains(a); override def elements : MutableIterator[A] = super.elements; override def size = underlying.size; override def hasAll(that : Iterable[A]) = that match { - case that : CollectionWrapper[_] => underlying.containsAll(that.underlying); + case that : CollectionWrapper[_] => + val u = underlying; + u.containsAll(that.underlying); case _ => super.hasAll(that); } override def add(a : A) = underlying.add(a); diff --git a/src/library/scala/collection/jcl/HashMap.scala b/src/library/scala/collection/jcl/HashMap.scala index 559255b070..cff07fe4ea 100644 --- a/src/library/scala/collection/jcl/HashMap.scala +++ b/src/library/scala/collection/jcl/HashMap.scala @@ -14,6 +14,6 @@ package scala.collection.jcl; * * @author Sean McDirmid */ -class HashMap[K,E](override val underlying: java.util.HashMap) extends MapWrapper[K,E] { - def this() = this(new java.util.HashMap); +class HashMap[K,E](override val underlying: java.util.HashMap[K,E]) extends MapWrapper[K,E] { + def this() = this(new java.util.HashMap[K,E]); } diff --git a/src/library/scala/collection/jcl/HashSet.scala b/src/library/scala/collection/jcl/HashSet.scala index 4f5848c209..09318cdcef 100644 --- a/src/library/scala/collection/jcl/HashSet.scala +++ b/src/library/scala/collection/jcl/HashSet.scala @@ -14,7 +14,7 @@ package scala.collection.jcl; * * @author Sean McDirmid */ -class HashSet[A](override val underlying: java.util.HashSet) extends SetWrapper[A] { +class HashSet[A](override val underlying: java.util.HashSet[A]) extends SetWrapper[A] { /** Creates an underlying Java hash set. */ - def this() = this(new java.util.HashSet); + def this() = this(new java.util.HashSet[A]); } diff --git a/src/library/scala/collection/jcl/IdentityHashMap.scala b/src/library/scala/collection/jcl/IdentityHashMap.scala index a56a49c844..6fdc7c827f 100644 --- a/src/library/scala/collection/jcl/IdentityHashMap.scala +++ b/src/library/scala/collection/jcl/IdentityHashMap.scala @@ -17,6 +17,6 @@ package scala.collection.jcl; * * @author Sean McDirmid */ -class IdentityHashMap[K,E](override val underlying : java.util.IdentityHashMap) extends MapWrapper[K,E] { - def this() = this(new java.util.IdentityHashMap); +class IdentityHashMap[K,E](override val underlying : java.util.IdentityHashMap[K,E]) extends MapWrapper[K,E] { + def this() = this(new java.util.IdentityHashMap[K,E]); } diff --git a/src/library/scala/collection/jcl/IterableWrapper.scala b/src/library/scala/collection/jcl/IterableWrapper.scala index a0c1c1d51a..ade058eb3b 100644 --- a/src/library/scala/collection/jcl/IterableWrapper.scala +++ b/src/library/scala/collection/jcl/IterableWrapper.scala @@ -15,7 +15,7 @@ package scala.collection.jcl; * @author Sean McDirmid */ trait IterableWrapper[A] extends MutableIterable[A] { - def underlying: java.util.Collection; + def underlying: java.util.Collection[A]; override def remove(a: A) = underlying.remove(a); override def removeAll(that: Iterable[A]) = that match { case that: IterableWrapper[_] => underlying.removeAll(that.underlying); diff --git a/src/library/scala/collection/jcl/LinkedHashMap.scala b/src/library/scala/collection/jcl/LinkedHashMap.scala index b86b171fb8..0c895a7ff8 100644 --- a/src/library/scala/collection/jcl/LinkedHashMap.scala +++ b/src/library/scala/collection/jcl/LinkedHashMap.scala @@ -15,6 +15,6 @@ package scala.collection.jcl; * * @author Sean McDirmid */ -class LinkedHashMap[K,E](override val underlying: java.util.LinkedHashMap) extends MapWrapper[K,E] { - def this() = this(new java.util.LinkedHashMap); +class LinkedHashMap[K,E](override val underlying: java.util.LinkedHashMap[K,E]) extends MapWrapper[K,E] { + def this() = this(new java.util.LinkedHashMap[K,E]); } diff --git a/src/library/scala/collection/jcl/LinkedHashSet.scala b/src/library/scala/collection/jcl/LinkedHashSet.scala index 57f0d737d5..2c7b14862f 100644 --- a/src/library/scala/collection/jcl/LinkedHashSet.scala +++ b/src/library/scala/collection/jcl/LinkedHashSet.scala @@ -15,6 +15,6 @@ package scala.collection.jcl; * * @author Sean McDirmid */ -class LinkedHashSet[A](override val underlying: java.util.LinkedHashSet) extends SetWrapper[A] { - def this() = this(new java.util.LinkedHashSet); +class LinkedHashSet[A](override val underlying: java.util.LinkedHashSet[A]) extends SetWrapper[A] { + def this() = this(new java.util.LinkedHashSet[A]); } diff --git a/src/library/scala/collection/jcl/LinkedList.scala b/src/library/scala/collection/jcl/LinkedList.scala index 535c926f46..5d94c964f1 100644 --- a/src/library/scala/collection/jcl/LinkedList.scala +++ b/src/library/scala/collection/jcl/LinkedList.scala @@ -16,8 +16,8 @@ package scala.collection.jcl; * * @author Sean McDirmid */ -class LinkedList[A](override val underlying : java.util.LinkedList) extends BufferWrapper[A] { - def this() = this(new java.util.LinkedList); +class LinkedList[A](override val underlying : java.util.LinkedList[A]) extends BufferWrapper[A] { + def this() = this(new java.util.LinkedList[A]); override def elements = super[BufferWrapper].elements; override def add(idx : Int, a : A) = if (idx == 0) underlying.addFirst(a); diff --git a/src/library/scala/collection/jcl/MapWrapper.scala b/src/library/scala/collection/jcl/MapWrapper.scala index 7e6c491289..aacb5c4e9f 100644 --- a/src/library/scala/collection/jcl/MapWrapper.scala +++ b/src/library/scala/collection/jcl/MapWrapper.scala @@ -15,7 +15,7 @@ package scala.collection.jcl; * @author Sean McDirmid */ trait MapWrapper[K,E] extends jcl.Map[K,E] { - def underlying : java.util.Map; + def underlying : java.util.Map[K,E]; override def size = underlying.size; override def isEmpty = underlying.isEmpty; override def clear() = underlying.clear; @@ -46,7 +46,7 @@ trait MapWrapper[K,E] extends jcl.Map[K,E] { def hasNext = underlying.hasNext; def remove = underlying.remove; def next = { - val next = underlying.next.asInstanceOf[java.util.Map.Entry]; + val next = underlying.next.asInstanceOf[java.util.Map.Entry[K,E]]; Tuple2(next.getKey.asInstanceOf[K],next.getValue.asInstanceOf[E]); } } diff --git a/src/library/scala/collection/jcl/MutableIterator.scala b/src/library/scala/collection/jcl/MutableIterator.scala index b887e3c76f..5f92746358 100644 --- a/src/library/scala/collection/jcl/MutableIterator.scala +++ b/src/library/scala/collection/jcl/MutableIterator.scala @@ -11,7 +11,7 @@ package scala.collection.jcl; object MutableIterator { - class Wrapper[A](val underlying : java.util.Iterator) extends MutableIterator[A] { + class Wrapper[A](val underlying : java.util.Iterator[A]) extends MutableIterator[A] { def hasNext = underlying.hasNext; def next = underlying.next.asInstanceOf[A]; def remove = underlying.remove; diff --git a/src/library/scala/collection/jcl/Ranged.scala b/src/library/scala/collection/jcl/Ranged.scala index 94759be0d1..054d9c381d 100644 --- a/src/library/scala/collection/jcl/Ranged.scala +++ b/src/library/scala/collection/jcl/Ranged.scala @@ -46,11 +46,9 @@ trait Ranged[K,A] extends scala.collection.Ranged[K,A] with MutableIterable[A] { override final def range(from: K, until: K) : SortedSelf = rangeImpl(Some(from),Some(until)); /** A wrapper around Java comparators. */ - protected class Comparator[K <% Ordered[K]] extends java.util.Comparator { + protected class Comparator[K <% Ordered[K]] extends java.util.Comparator[Any] { def compare(x0 : Any, x1 : Any) = { - val k0 = x0.asInstanceOf[K]; - val k1 = x1.asInstanceOf[K]; - k0.compare(k1); + x0.asInstanceOf[K].compare(x1.asInstanceOf[K]); //!!! } } } diff --git a/src/library/scala/collection/jcl/SetWrapper.scala b/src/library/scala/collection/jcl/SetWrapper.scala index f60c9b5fbe..5aeaf57a1b 100644 --- a/src/library/scala/collection/jcl/SetWrapper.scala +++ b/src/library/scala/collection/jcl/SetWrapper.scala @@ -15,7 +15,7 @@ package scala.collection.jcl; * @author Sean McDirmid */ trait SetWrapper[A] extends Set[A] with CollectionWrapper[A] { - def underlying: java.util.Set; + def underlying: java.util.Set[A]; override def isEmpty = super[CollectionWrapper].isEmpty; override def clear() = super[CollectionWrapper].clear; override def size = underlying.size; diff --git a/src/library/scala/collection/jcl/SortedMapWrapper.scala b/src/library/scala/collection/jcl/SortedMapWrapper.scala index a71ed832e8..c706a4fec9 100644 --- a/src/library/scala/collection/jcl/SortedMapWrapper.scala +++ b/src/library/scala/collection/jcl/SortedMapWrapper.scala @@ -15,7 +15,7 @@ package scala.collection.jcl; * @author Sean McDirmid */ trait SortedMapWrapper[K,E] extends SortedMap[K,E] with MapWrapper[K,E] { - override def underlying : java.util.SortedMap; + override def underlying : java.util.SortedMap[K,E]; /** the comparator function of this sorted map is defined in terms * of the underlying sorted map's comparator. */ diff --git a/src/library/scala/collection/jcl/SortedSetWrapper.scala b/src/library/scala/collection/jcl/SortedSetWrapper.scala index 0021d09031..39b066bfd7 100644 --- a/src/library/scala/collection/jcl/SortedSetWrapper.scala +++ b/src/library/scala/collection/jcl/SortedSetWrapper.scala @@ -20,7 +20,7 @@ package scala.collection.jcl; * @author Sean McDirmid */ trait SortedSetWrapper[A] extends SortedSet[A] with SetWrapper[A] { - def underlying : java.util.SortedSet; + def underlying : java.util.SortedSet[A]; /** delegates to the comparator of the underlying Java sorted set */ override def compare(a0 : A, a1 : A) = underlying.comparator.compare(a0, a1); override def firstKey = underlying.first.asInstanceOf[A]; diff --git a/src/library/scala/collection/jcl/TreeMap.scala b/src/library/scala/collection/jcl/TreeMap.scala index 403ee6c5cf..a92d5b8c43 100644 --- a/src/library/scala/collection/jcl/TreeMap.scala +++ b/src/library/scala/collection/jcl/TreeMap.scala @@ -15,5 +15,5 @@ package scala.collection.jcl; * @author Sean McDirmid */ class TreeMap[K <% Ordered[K],E] extends SortedMapWrapper[K,E] { - val underlying = (new java.util.TreeMap(new Comparator[K])); + val underlying = (new java.util.TreeMap[K,E](new Comparator[K])); } diff --git a/src/library/scala/collection/jcl/TreeSet.scala b/src/library/scala/collection/jcl/TreeSet.scala index 55d4943a7c..d2bbb5052a 100644 --- a/src/library/scala/collection/jcl/TreeSet.scala +++ b/src/library/scala/collection/jcl/TreeSet.scala @@ -16,5 +16,5 @@ package scala.collection.jcl; * @author Sean McDirmid */ class TreeSet[A <% Ordered[A]] extends SortedSetWrapper[A] { - val underlying = new java.util.TreeSet(new Comparator[A]); + val underlying = new java.util.TreeSet[A](new Comparator[A]); } diff --git a/src/library/scala/collection/jcl/WeakHashMap.scala b/src/library/scala/collection/jcl/WeakHashMap.scala index c2d6239a80..35590a639c 100644 --- a/src/library/scala/collection/jcl/WeakHashMap.scala +++ b/src/library/scala/collection/jcl/WeakHashMap.scala @@ -24,6 +24,6 @@ package scala.collection.jcl; * * @author Sean McDirmid */ -class WeakHashMap[K,E](override val underlying: java.util.WeakHashMap) extends MapWrapper[K,E] { - def this() = this(new java.util.WeakHashMap); +class WeakHashMap[K,E](override val underlying: java.util.WeakHashMap[K,E]) extends MapWrapper[K,E] { + def this() = this(new java.util.WeakHashMap[K,E]) } diff --git a/src/library/scala/collection/mutable/JavaMapAdaptor.scala b/src/library/scala/collection/mutable/JavaMapAdaptor.scala index 02bfc06961..345fb324bb 100644 --- a/src/library/scala/collection/mutable/JavaMapAdaptor.scala +++ b/src/library/scala/collection/mutable/JavaMapAdaptor.scala @@ -18,7 +18,7 @@ package scala.collection.mutable * @author Matthias Zenger * @version 1.0, 21/07/2003 */ -@deprecated class JavaMapAdaptor[A, B](jmap: java.util.Map) extends Map[A, B] { +@deprecated class JavaMapAdaptor[A, B](jmap: java.util.Map[A, B]) extends Map[A, B] { def size: Int = jmap.size() diff --git a/src/library/scala/collection/mutable/JavaSetAdaptor.scala b/src/library/scala/collection/mutable/JavaSetAdaptor.scala index 51e48d122d..95aaba59d0 100644 --- a/src/library/scala/collection/mutable/JavaSetAdaptor.scala +++ b/src/library/scala/collection/mutable/JavaSetAdaptor.scala @@ -18,7 +18,7 @@ package scala.collection.mutable * @author Matthias Zenger * @version 1.0, 19/09/2003 */ -@deprecated class JavaSetAdaptor[A](jset: java.util.Set) extends Set[A] { +@deprecated class JavaSetAdaptor[A](jset: java.util.Set[A]) extends Set[A] { def size: Int = jset.size() diff --git a/src/library/scala/collection/mutable/LinkedHashSet.scala b/src/library/scala/collection/mutable/LinkedHashSet.scala index ed0ef128a4..21fd4845fb 100644 --- a/src/library/scala/collection/mutable/LinkedHashSet.scala +++ b/src/library/scala/collection/mutable/LinkedHashSet.scala @@ -15,12 +15,12 @@ package scala.collection.mutable * @author Sean McDirmid * @version 1.0 */ -@deprecated class LinkedHashSet[A](private val set0 : java.util.LinkedHashSet) extends Set[A] { +@deprecated class LinkedHashSet[A](private val set0 : java.util.LinkedHashSet[A]) extends Set[A] { - def this() = this(new java.util.LinkedHashSet) + def this() = this(new java.util.LinkedHashSet[A]) - private def this(set1 : java.util.Set, b : Boolean) = - this(new java.util.LinkedHashSet(set1)) + private def this(set1 : java.util.Set[A], b : Boolean) = + this(new java.util.LinkedHashSet[A](set1)) def contains(elem: A): Boolean = set0.contains(elem) diff --git a/src/library/scala/compat/Platform.scala b/src/library/scala/compat/Platform.scala index 7d0cec4b72..1fd2962add 100644 --- a/src/library/scala/compat/Platform.scala +++ b/src/library/scala/compat/Platform.scala @@ -37,12 +37,12 @@ object Platform { * @param length .. * @return .. */ - def createArray(elemClass: Class, length: Int): AnyRef = + def createArray(elemClass: Class[_], length: Int): AnyRef = java.lang.reflect.Array.newInstance(elemClass, length) def arrayclear(arr: Array[Int]): Unit = java.util.Arrays.fill(arr, 0) - def getClassForName(name: String): Class = java.lang.Class.forName(name) + def getClassForName(name: String): Class[_] = java.lang.Class.forName(name) val EOL = System.getProperty("line.separator", "\n") diff --git a/src/library/scala/mobile/Code.scala b/src/library/scala/mobile/Code.scala index b462876ad1..f34d39e24a 100644 --- a/src/library/scala/mobile/Code.scala +++ b/src/library/scala/mobile/Code.scala @@ -32,7 +32,7 @@ import java.lang.NoSuchMethodException * @author Stephane Micheloud * @version 1.0, 04/05/2004 */ -class Code(clazz: java.lang.Class) { +class Code(clazz: java.lang.Class[_]) { private type JObject = java.lang.Object @@ -40,10 +40,12 @@ class Code(clazz: java.lang.Class) { ///////////////////////////// apply methods /////////////////////////////// + type AnyClass = Class[T] forSome { type T } + def apply[R](funName: String) = () => { val args = Array[JObject]() - val types = Array[Class]() + val types = Array[AnyClass]() applyFun(funName, args, types).asInstanceOf[R] } @@ -51,7 +53,7 @@ class Code(clazz: java.lang.Class) { (_0: A0) => { val p = boxValue(_0) val args = Array(p._1) - val types = Array(p._2) + val types = Array[AnyClass](p._2) applyFun(funName, args, types).asInstanceOf[R] } @@ -60,7 +62,7 @@ class Code(clazz: java.lang.Class) { val p0 = boxValue(_0) val p1 = boxValue(_1) val args = Array(p0._1, p1._1) - val types = Array(p0._2, p1._2) + val types = Array[AnyClass](p0._2, p1._2) applyFun(funName, args, types).asInstanceOf[R] } @@ -70,7 +72,7 @@ class Code(clazz: java.lang.Class) { val p1 = boxValue(_1) val p2 = boxValue(_2) val args = Array(p0._1, p1._1, p2._1) - val types = Array(p0._2, p1._2, p2._2) + val types = Array[AnyClass](p0._2, p1._2, p2._2) applyFun(funName, args, types).asInstanceOf[R] } @@ -81,7 +83,7 @@ class Code(clazz: java.lang.Class) { val p2 = boxValue(_2) val p3 = boxValue(_3) val args = Array(p0._1, p1._1, p2._1, p3._1) - val types = Array(p0._2, p1._2, p2._2, p3._2) + val types = Array[AnyClass](p0._2, p1._2, p2._2, p3._2) applyFun(funName, args, types).asInstanceOf[R] } @@ -93,7 +95,7 @@ class Code(clazz: java.lang.Class) { val p3 = boxValue(_3) val p4 = boxValue(_4) val args = Array(p0._1, p1._1, p2._1, p3._1, p4._1) - val types = Array(p0._2, p1._2, p2._2, p3._2, p4._2) + val types = Array[AnyClass](p0._2, p1._2, p2._2, p3._2, p4._2) applyFun(funName, args, types).asInstanceOf[R] } @@ -106,7 +108,7 @@ class Code(clazz: java.lang.Class) { val p4 = boxValue(_4) val p5 = boxValue(_5) val args = Array(p0._1, p1._1, p2._1, p3._1, p4._1, p5._1) - val types = Array(p0._2, p1._2, p2._2, p3._2, p4._2, p5._2) + val types = Array[AnyClass](p0._2, p1._2, p2._2, p3._2, p4._2, p5._2) applyFun(funName, args, types).asInstanceOf[R] } @@ -120,7 +122,7 @@ class Code(clazz: java.lang.Class) { val p5 = boxValue(_5) val p6 = boxValue(_6) val args = Array(p0._1, p1._1, p2._1, p3._1, p4._1, p5._1, p6._1) - val types = Array(p0._2, p1._2, p2._2, p3._2, p4._2, p5._2, p6._2) + val types = Array[AnyClass](p0._2, p1._2, p2._2, p3._2, p4._2, p5._2, p6._2) applyFun(funName, args, types).asInstanceOf[R] } @@ -135,7 +137,7 @@ class Code(clazz: java.lang.Class) { val p6 = boxValue(_6) val p7 = boxValue(_7) val args = Array(p0._1, p1._1, p2._1, p3._1, p4._1, p5._1, p6._1, p7._1) - val types = Array(p0._2, p1._2, p2._2, p3._2, p4._2, p5._2, p6._2, p7._2) + val types = Array[AnyClass](p0._2, p1._2, p2._2, p3._2, p4._2, p5._2, p6._2, p7._2) applyFun(funName, args, types).asInstanceOf[R] } @@ -151,7 +153,7 @@ class Code(clazz: java.lang.Class) { val p7 = boxValue(_7) val p8 = boxValue(_8) val args = Array(p0._1, p1._1, p2._1, p3._1, p4._1, p5._1, p6._1, p7._1, p8._1) - val types = Array(p0._2, p1._2, p2._2, p3._2, p4._2, p5._2, p6._2, p7._2, p8._2) + val types = Array[AnyClass](p0._2, p1._2, p2._2, p3._2, p4._2, p5._2, p6._2, p7._2, p8._2) applyFun(funName, args, types).asInstanceOf[R] } @@ -180,19 +182,20 @@ class Code(clazz: java.lang.Class) { methName.equals(className) } - private def applyFun(methName: String, args: Array[JObject], argTypes: Array[Class]): JObject = { + private def applyFun(methName: String, args: Array[JObject], + argTypes: Array[Class[T] forSome { type T }]): JObject = { try { val method = clazz.getMethod(methName, argTypes) var obj: JObject = null if (! Modifier.isStatic(method.getModifiers())) { if (instance eq null) { instance = try { - clazz.newInstance() + clazz.newInstance().asInstanceOf[AnyRef] } catch { case _ => val cs = clazz.getConstructors() //Console.println("cs.length=" + cs.length); if (cs.length > 0) { - cs(0).newInstance(Array("")) + cs(0).newInstance(Array("")).asInstanceOf[AnyRef] } else { error("class " + clazz.getName() + " has no public constructor") null @@ -209,7 +212,7 @@ class Code(clazz: java.lang.Class) { if (isConstructorName(methName)) { try { val cstr = clazz.getConstructor(argTypes) - instance = cstr.newInstance(args) + instance = cstr.newInstance(args).asInstanceOf[AnyRef] instance } catch { diff --git a/src/library/scala/mobile/Location.scala b/src/library/scala/mobile/Location.scala index bcb66387e5..1048b403e7 100644 --- a/src/library/scala/mobile/Location.scala +++ b/src/library/scala/mobile/Location.scala @@ -55,7 +55,7 @@ class Location(url: URL) { /** A cache containing all classes of this location. */ - private var ccache: Map[String, java.lang.Class] = new HashMap + private var ccache: Map[String, java.lang.Class[T] forSome { type T }] = new HashMap /** Return the code description for the string <code>className</code> * at this location. diff --git a/src/library/scala/ref/PhantomReference.scala b/src/library/scala/ref/PhantomReference.scala index 20cd1fa093..d3519ea438 100644 --- a/src/library/scala/ref/PhantomReference.scala +++ b/src/library/scala/ref/PhantomReference.scala @@ -14,5 +14,6 @@ package scala.ref * @author Sean McDirmid */ class PhantomReference[+T <: AnyRef](value: T, queue: ReferenceQueue[T]) extends ReferenceWrapper[T] { - val underlying = new java.lang.ref.PhantomReference(value, queue.underlying) + val underlying: java.lang.ref.PhantomReference[_ <: T] = + new java.lang.ref.PhantomReference(value, queue.underlying) } diff --git a/src/library/scala/ref/ReferenceQueue.scala b/src/library/scala/ref/ReferenceQueue.scala index 5f2d7a20ec..486c5be975 100644 --- a/src/library/scala/ref/ReferenceQueue.scala +++ b/src/library/scala/ref/ReferenceQueue.scala @@ -14,10 +14,10 @@ package scala.ref * @author Sean McDirmid */ class ReferenceQueue[+T <: AnyRef] { - private[ref] val underlying = new java.lang.ref.ReferenceQueue + private[ref] val underlying: java.lang.ref.ReferenceQueue[_ <: T] = new java.lang.ref.ReferenceQueue[T] override def toString = underlying.toString; - class Wrapper(val underlying: java.lang.ref.Reference) extends ReferenceWrapper[T] - def Wrapper(ref: java.lang.ref.Reference) = ref match { + class Wrapper[U <: AnyRef](val underlying: java.lang.ref.Reference[U]) extends ReferenceWrapper[U] + def Wrapper[U <: AnyRef](ref: java.lang.ref.Reference[U]) = ref match { case null => None case ref => new Wrapper(ref) } diff --git a/src/library/scala/ref/ReferenceWrapper.scala b/src/library/scala/ref/ReferenceWrapper.scala index d0adb559d7..7c01e121d9 100644 --- a/src/library/scala/ref/ReferenceWrapper.scala +++ b/src/library/scala/ref/ReferenceWrapper.scala @@ -14,7 +14,7 @@ package scala.ref * @author Seam McDirmid */ trait ReferenceWrapper[+T <: AnyRef] extends Reference[T] { - val underlying: java.lang.ref.Reference + val underlying: java.lang.ref.Reference[_ <: T] @deprecated def isValid = underlying.get != null override def get = { val ret = underlying.get.asInstanceOf[T] diff --git a/src/library/scala/ref/SoftReference.scala b/src/library/scala/ref/SoftReference.scala index 8c6622c7e9..0a0b3642e7 100644 --- a/src/library/scala/ref/SoftReference.scala +++ b/src/library/scala/ref/SoftReference.scala @@ -15,7 +15,7 @@ package scala.ref */ class SoftReference[+T <: AnyRef](value : T, queue : ReferenceQueue[T]) extends ReferenceWrapper[T] { def this(value : T) = this(value, null); - val underlying = + val underlying: java.lang.ref.SoftReference[_ <: T] = if (queue == null) new java.lang.ref.SoftReference(value); else new java.lang.ref.SoftReference(value, queue.underlying); } diff --git a/src/library/scala/ref/WeakReference.scala b/src/library/scala/ref/WeakReference.scala index bde3a6c4fa..c1ec3f8ff5 100644 --- a/src/library/scala/ref/WeakReference.scala +++ b/src/library/scala/ref/WeakReference.scala @@ -15,7 +15,7 @@ package scala.ref */ class WeakReference[+T <: AnyRef](value: T, queue: ReferenceQueue[T]) extends ReferenceWrapper[T] { def this(value: T) = this(value, null) - val underlying = + val underlying: java.lang.ref.WeakReference[_ <: T] = if (queue == null) new java.lang.ref.WeakReference(value) else new java.lang.ref.WeakReference(value, queue.underlying) } diff --git a/src/library/scala/runtime/BoxedAnyArray.scala b/src/library/scala/runtime/BoxedAnyArray.scala index 316c085aa1..3e532cb5d5 100644 --- a/src/library/scala/runtime/BoxedAnyArray.scala +++ b/src/library/scala/runtime/BoxedAnyArray.scala @@ -27,7 +27,7 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray { private var boxed = new Array[AnyRef](length) private val hash = boxed.hashCode() private var unboxed: AnyRef = null - private var elemClass: Class = null + private var elemClass: Class[_] = null def apply(index: Int): Any = synchronized { if (unboxed eq null) @@ -87,7 +87,7 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray { else if (elemTag eq ScalaRunTime.BooleanTag) unbox(classOf[Boolean]) else unbox(Platform.getClassForName(elemTag)) - def unbox(elemClass: Class): AnyRef = synchronized { + def unbox(elemClass: Class[_]): AnyRef = synchronized { if (unboxed eq null) { this.elemClass = elemClass; if (elemClass eq classOf[Int]) { diff --git a/src/library/scala/runtime/BoxedArray.scala b/src/library/scala/runtime/BoxedArray.scala index 1cffb0b469..8975aac106 100644 --- a/src/library/scala/runtime/BoxedArray.scala +++ b/src/library/scala/runtime/BoxedArray.scala @@ -39,7 +39,7 @@ abstract class BoxedArray extends Array.Array0[Any] { //todo: remove def unbox(elemTag: String): AnyRef - def unbox(elemClass: Class): AnyRef + def unbox(elemClass: Class[_]): AnyRef override def isDefinedAt(x: Int): Boolean = 0 <= x && x < length diff --git a/src/library/scala/runtime/BoxedBooleanArray.scala b/src/library/scala/runtime/BoxedBooleanArray.scala index 6e55ec3692..045521b1cb 100644 --- a/src/library/scala/runtime/BoxedBooleanArray.scala +++ b/src/library/scala/runtime/BoxedBooleanArray.scala @@ -26,7 +26,7 @@ final class BoxedBooleanArray(val value: Array[Boolean]) extends BoxedArray { } def unbox(elemTag: String): AnyRef = value - def unbox(elemClass: Class): AnyRef = value + def unbox(elemClass: Class[_]): AnyRef = value override def equals(other: Any) = value == other || diff --git a/src/library/scala/runtime/BoxedByteArray.scala b/src/library/scala/runtime/BoxedByteArray.scala index 91b7fca7ce..f61c18b61e 100644 --- a/src/library/scala/runtime/BoxedByteArray.scala +++ b/src/library/scala/runtime/BoxedByteArray.scala @@ -26,7 +26,7 @@ final class BoxedByteArray(val value: Array[Byte]) extends BoxedArray { } def unbox(elemTag: String): AnyRef = value - def unbox(elemClass: Class): AnyRef = value + def unbox(elemClass: Class[_]): AnyRef = value override def equals(other: Any) = value == other || diff --git a/src/library/scala/runtime/BoxedCharArray.scala b/src/library/scala/runtime/BoxedCharArray.scala index ef5674f713..a012749e5c 100644 --- a/src/library/scala/runtime/BoxedCharArray.scala +++ b/src/library/scala/runtime/BoxedCharArray.scala @@ -26,7 +26,7 @@ final class BoxedCharArray(val value: Array[Char]) extends BoxedArray { } def unbox(elemTag: String): AnyRef = value - def unbox(elemClass: Class): AnyRef = value + def unbox(elemClass: Class[_]): AnyRef = value override def equals(other: Any) = ( value == other || diff --git a/src/library/scala/runtime/BoxedDoubleArray.scala b/src/library/scala/runtime/BoxedDoubleArray.scala index 5877eaae09..1157cf45ca 100644 --- a/src/library/scala/runtime/BoxedDoubleArray.scala +++ b/src/library/scala/runtime/BoxedDoubleArray.scala @@ -26,7 +26,7 @@ final class BoxedDoubleArray(val value: Array[Double]) extends BoxedArray { } def unbox(elemTag: String): AnyRef = value - def unbox(elemClass: Class): AnyRef = value + def unbox(elemClass: Class[_]): AnyRef = value override def equals(other: Any) = value == other || diff --git a/src/library/scala/runtime/BoxedFloatArray.scala b/src/library/scala/runtime/BoxedFloatArray.scala index 3cf6b36938..0aa3f80729 100644 --- a/src/library/scala/runtime/BoxedFloatArray.scala +++ b/src/library/scala/runtime/BoxedFloatArray.scala @@ -26,7 +26,7 @@ final class BoxedFloatArray(val value: Array[Float]) extends BoxedArray { } def unbox(elemTag: String): AnyRef = value - def unbox(elemClass: Class): AnyRef = value + def unbox(elemClass: Class[_]): AnyRef = value override def equals(other: Any) = value == other || diff --git a/src/library/scala/runtime/BoxedIntArray.scala b/src/library/scala/runtime/BoxedIntArray.scala index ed79f0c4da..17e244eb3a 100644 --- a/src/library/scala/runtime/BoxedIntArray.scala +++ b/src/library/scala/runtime/BoxedIntArray.scala @@ -26,7 +26,7 @@ final class BoxedIntArray(val value: Array[Int]) extends BoxedArray { } def unbox(elemTag: String): AnyRef = value - def unbox(elemClass: Class): AnyRef = value + def unbox(elemClass: Class[_]): AnyRef = value override def equals(other: Any) = value == other || diff --git a/src/library/scala/runtime/BoxedLongArray.scala b/src/library/scala/runtime/BoxedLongArray.scala index 8dbf87edf1..bbe6858883 100644 --- a/src/library/scala/runtime/BoxedLongArray.scala +++ b/src/library/scala/runtime/BoxedLongArray.scala @@ -26,7 +26,7 @@ final class BoxedLongArray(val value: Array[Long]) extends BoxedArray { } def unbox(elemTag: String): AnyRef = value - def unbox(elemClass: Class): AnyRef = value + def unbox(elemClass: Class[_]): AnyRef = value override def equals(other: Any) = value == other || diff --git a/src/library/scala/runtime/BoxedObjectArray.scala b/src/library/scala/runtime/BoxedObjectArray.scala index cc91ab7dba..5f9bc7e998 100644 --- a/src/library/scala/runtime/BoxedObjectArray.scala +++ b/src/library/scala/runtime/BoxedObjectArray.scala @@ -27,7 +27,7 @@ final class BoxedObjectArray(val value: Array[AnyRef]) extends BoxedArray { } def unbox(elemTag: String): AnyRef = value - def unbox(elemClass: Class): AnyRef = value + def unbox(elemClass: Class[_]): AnyRef = value override def equals(other: Any): Boolean = value == other || diff --git a/src/library/scala/runtime/BoxedShortArray.scala b/src/library/scala/runtime/BoxedShortArray.scala index 7f3e2c09e1..9921bb79f6 100644 --- a/src/library/scala/runtime/BoxedShortArray.scala +++ b/src/library/scala/runtime/BoxedShortArray.scala @@ -26,7 +26,7 @@ final class BoxedShortArray(val value: Array[Short]) extends BoxedArray { } def unbox(elemTag: String): AnyRef = value - def unbox(elemClass: Class): AnyRef = value + def unbox(elemClass: Class[_]): AnyRef = value override def equals(other: Any) = value == other || diff --git a/src/library/scala/runtime/Nothing$.scala b/src/library/scala/runtime/Nothing$.scala index 0151f95c41..e2d9ca8484 100644 --- a/src/library/scala/runtime/Nothing$.scala +++ b/src/library/scala/runtime/Nothing$.scala @@ -6,7 +6,7 @@ ** |/ ** \* */ -// $Id: Nothing$.scala 10086 2007-02-21 19:10:41Z odersky $ +// $Id: Nothing$.scala 10642 2007-04-06 09:23:03Z moors $ package scala.runtime diff --git a/src/library/scala/runtime/Null$.scala b/src/library/scala/runtime/Null$.scala index 3dd19efeb0..e796b21a49 100644 --- a/src/library/scala/runtime/Null$.scala +++ b/src/library/scala/runtime/Null$.scala @@ -6,7 +6,7 @@ ** |/ ** \* */ -// $Id: Null$.scala 10086 2007-02-21 19:10:41Z odersky $ +// $Id: Null$.scala 10642 2007-04-06 09:23:03Z moors $ package scala.runtime diff --git a/src/library/scala/runtime/RichInt.scala b/src/library/scala/runtime/RichInt.scala index 6becda3a59..1af3d4653e 100644 --- a/src/library/scala/runtime/RichInt.scala +++ b/src/library/scala/runtime/RichInt.scala @@ -27,7 +27,7 @@ final class RichInt(start: Int) extends Proxy with Ordered[Int] { def until(end: Int, step: Int): Range = Iterator.range(start, end, step) /** like <code>until</code>, but includes the last index */ - def to(end: Int) : Range = until(end).inclusive + def to(end: Int) = until(end + 1) def min(that: Int): Int = if (start < that) start else that def max(that: Int): Int = if (start > that) start else that diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala index 947c02613b..d7a0776f36 100644 --- a/src/library/scala/runtime/ScalaRunTime.scala +++ b/src/library/scala/runtime/ScalaRunTime.scala @@ -28,30 +28,27 @@ object ScalaRunTime { val DoubleTag = ".Double" val BooleanTag = ".Boolean" - def isArray(x: AnyRef): Boolean = - (x != null && x.getClass.isArray) || (x != null && x.isInstanceOf[BoxedArray]) - + def isArray(x: AnyRef): Boolean = (x != null && x.getClass.isArray) || (x != null && x.isInstanceOf[BoxedArray]) def isValueTag(tag: String) = tag.charAt(0) == '.' - - def isValueClass(clazz: Class) = clazz.isPrimitive() + def isValueClass(clazz: Class[_]) = clazz.isPrimitive() def checkInitialized[T <: AnyRef](x: T): T = if (x == null) throw new UninitializedError else x - abstract class Try[A] { - def Catch[B >: A](handler: PartialFunction[Throwable, B]): B - def Finally(handler: Unit): A + abstract class Try[a] { + def Catch[b >: a](handler: PartialFunction[Throwable, b]): b + def Finally(handler: Unit): a } - def Try[A](block: => A): Try[A] = new Try[A] with Runnable { - var result: A = _ + def Try[a](block: => a): Try[a] = new Try[a] with Runnable { + var result: a = _ var exception: Throwable = ExceptionHandling.tryCatch(this) - def run() { result = block } + def run(): Unit = result = block - def Catch[B >: A](handler: PartialFunction[Throwable, B]): B = + def Catch[b >: a](handler: PartialFunction[Throwable, b]): b = if (exception eq null) - result.asInstanceOf[B] + result.asInstanceOf[b] // !!! else if (exception is LocalReturn) // !!! // ... else if (handler isDefinedAt exception) @@ -59,9 +56,9 @@ object ScalaRunTime { else throw exception - def Finally(handler: Unit): A = + def Finally(handler: Unit): a = if (exception eq null) - result.asInstanceOf[A] + result.asInstanceOf[a] else throw exception } @@ -82,8 +79,7 @@ object ScalaRunTime { val arr = x.productArity var i = 0 while (i < arr) { - val elem = x.productElement(i) - code = code * 41 + (if (elem == null) 0 else elem.hashCode()) + code = code * 41 + x.productElement(i).hashCode() i += 1 } code @@ -121,12 +117,12 @@ object ScalaRunTime { //def checkDefined[T >: Null](x: T): T = // if (x == null) throw new UndefinedException else x - def Seq[A](xs: A*): Seq[A] = null // interpreted specially by new backend. + def Seq[a](xs: a*): Seq[a] = null // interpreted specially by new backend. def arrayValue(x: BoxedArray, elemTag: String): AnyRef = if (x eq null) null else x.unbox(elemTag) - def arrayValue(x: BoxedArray, elemClass: Class): AnyRef = + def arrayValue(x: BoxedArray, elemClass: Class[_]): AnyRef = if (x eq null) null else x.unbox(elemClass) def boxArray(value: AnyRef): BoxedArray = value match { diff --git a/src/library/scala/runtime/StringAdd.scala b/src/library/scala/runtime/StringAdd.scala index b3cad91df5..272e2cbb08 100644 --- a/src/library/scala/runtime/StringAdd.scala +++ b/src/library/scala/runtime/StringAdd.scala @@ -17,7 +17,7 @@ import Predef._ object StringAdd { // Needed for the format hack. Can be removed once we drop 1.4 lazy val formatMethod: java.lang.reflect.Method = { - val paramTypes = Array(classOf[String], classOf[Array[Object]]) + val paramTypes = Array[Class[T] forSome { type T }](classOf[String], classOf[Array[Object]]) classOf[String].getDeclaredMethod("format", paramTypes) } } diff --git a/src/library/scala/throws.scala b/src/library/scala/throws.scala index c93ec8d3c8..96b095b3fd 100644 --- a/src/library/scala/throws.scala +++ b/src/library/scala/throws.scala @@ -25,4 +25,4 @@ package scala * @author Nikolay Mihaylov * @version 1.0, 19/05/2006 */ -class throws(clazz: java.lang.Class) extends Annotation +class throws(clazz: java.lang.Class[_]) extends Annotation diff --git a/src/library/scala/util/DynamicVariable.scala b/src/library/scala/util/DynamicVariable.scala index d6718c6d52..d2fb855c7d 100644 --- a/src/library/scala/util/DynamicVariable.scala +++ b/src/library/scala/util/DynamicVariable.scala @@ -52,8 +52,8 @@ import java.lang.InheritableThreadLocal * @version 1.1, 2007-5-21 */ class DynamicVariable[T](init: T) { - private val tl = new InheritableThreadLocal { - override def initialValue = init.asInstanceOf[AnyRef] + private val tl = new InheritableThreadLocal[T] { + override def initialValue = init.asInstanceOf[T with AnyRef] } /** Retrieve the current value */ |