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 | |
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
60 files changed, 160 insertions, 138 deletions
diff --git a/lib/scala-compiler.jar.desired.sha1 b/lib/scala-compiler.jar.desired.sha1 index 3bf4eb36c1..d94d5aed1b 100644 --- a/lib/scala-compiler.jar.desired.sha1 +++ b/lib/scala-compiler.jar.desired.sha1 @@ -1 +1 @@ -c37ea17a89c5e64bdefd80a28532c8d982c11299 ?scala-compiler.jar +5ca5f465ee0cf5e17e2f51b256a7fe813d5be005 ?scala-compiler.jar diff --git a/lib/scala-library-src.jar.desired.sha1 b/lib/scala-library-src.jar.desired.sha1 index 5cebe88e62..05aa01ab3f 100644 --- a/lib/scala-library-src.jar.desired.sha1 +++ b/lib/scala-library-src.jar.desired.sha1 @@ -1 +1 @@ -f1634e7f5c1f6f7ed4e6a3eb872ff6b08ca9233b ?scala-library-src.jar +98df69d742b3323810c37fb9c36328c9bed50245 ?scala-library-src.jar diff --git a/lib/scala-library.jar.desired.sha1 b/lib/scala-library.jar.desired.sha1 index 47b07e4abc..ffa7465d0f 100644 --- a/lib/scala-library.jar.desired.sha1 +++ b/lib/scala-library.jar.desired.sha1 @@ -1 +1 @@ -1207e6fab978eeb71eff6bdc9d523db3cad63c3c ?scala-library.jar +93774afad0ec5a940628a89348e097050bb25467 ?scala-library.jar diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 9a746bf1f3..35810e560d 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -169,7 +169,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable } try { val clazz = Class.forName(settings.sourceReader.value) - val ccon = clazz.getConstructor(Array[Class](classOf[java.nio.charset.CharsetDecoder])) + val ccon = clazz.getConstructor(Array[Class[T] forSome { type T }](classOf[java.nio.charset.CharsetDecoder])) ccon.newInstance(Array[AnyRef] (charset.newDecoder())).asInstanceOf[SourceReader]; //new SourceReader(charset.newDecoder()) } catch { diff --git a/src/compiler/scala/tools/nsc/plugins/Plugin.scala b/src/compiler/scala/tools/nsc/plugins/Plugin.scala index 4f5e0a54bd..aa0a80e0aa 100644 --- a/src/compiler/scala/tools/nsc/plugins/Plugin.scala +++ b/src/compiler/scala/tools/nsc/plugins/Plugin.scala @@ -100,7 +100,7 @@ object Plugin { * if the jar file has no plugin in it or if the plugin * is badly formed. */ - def loadFrom(jarfile: File, loader: ClassLoader): Option[Class] = { + def loadFrom(jarfile: File, loader: ClassLoader): Option[Class[_]] = { val pluginInfo = loadDescription(jarfile).get try { @@ -120,7 +120,7 @@ object Plugin { */ def loadAllFrom(jars: List[File], dirs: List[File], - ignoring: List[String]): List[Class] = + ignoring: List[String]): List[Class[_]] = { val alljars = new ListBuffer[File] @@ -143,7 +143,7 @@ object Plugin { /** Instantiate a plugin class, given the class and * the compiler it is to be used in. */ - def instantiate(clazz: Class, global: Global): Plugin = { + def instantiate(clazz: Class[_], global: Global): Plugin = { val constructor = clazz.getConstructor(Array(classOf[Global])) constructor.newInstance(Array(global)).asInstanceOf[Plugin] } diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index c1c2448e31..d33c0dc652 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -1659,6 +1659,7 @@ A type's typeSymbol should never be inspected directly. { override protected def rewrap(newtp: Type) = existentialAbstraction(quantified, newtp) + override def isTrivial = false override def isStable: Boolean = false override def bounds = TypeBounds(maybeRewrap(underlying.bounds.lo), maybeRewrap(underlying.bounds.hi)) override def parents = underlying.parents map maybeRewrap @@ -2037,7 +2038,7 @@ A type's typeSymbol should never be inspected directly. /** A creator for type parameterizations * If tparams is empty, simply returns result type */ - def parameterizedType(tparams: List[Symbol], tpe: Type): Type = + def polyType(tparams: List[Symbol], tpe: Type): Type = if (tparams.isEmpty) tpe else PolyType(tparams, tpe match { @@ -2462,10 +2463,17 @@ A type's typeSymbol should never be inspected directly. private val emptySymMap = scala.collection.immutable.Map[Symbol, Symbol]() private val emptySymCount = scala.collection.immutable.Map[Symbol, Int]() - private def makeExistential(suffix: String, owner: Symbol, lo: Type, hi: Type) = + /** Make an existential variable. + * @param suffix A suffix to be appended to the freshly generated name + * It's ususally "", except for type variables abstracting + * over values, where it is ".type". + * @param owner The owner of the variable + * @param bounds The variable's bounds + */ + def makeExistential(suffix: String, owner: Symbol, bounds: TypeBounds): Symbol = recycle( owner.newAbstractType(owner.pos, newTypeName(freshTypeName()+suffix)).setFlag(EXISTENTIAL) - ).setInfo(TypeBounds(lo, hi)) + ).setInfo(bounds) /** A map to compute the asSeenFrom method */ class AsSeenFromMap(pre: Type, clazz: Symbol) extends TypeMap { @@ -2507,7 +2515,8 @@ A type's typeSymbol should never be inspected directly. def stabilize(pre: Type, clazz: Symbol): Type = { capturedPre get clazz match { case None => - val qvar = makeExistential(".type", clazz, AllClass.tpe, intersectionType(List(pre, SingletonClass.tpe))) + val qvar = makeExistential(".type", clazz, + mkTypeBounds(AllClass.tpe, intersectionType(List(pre, SingletonClass.tpe)))) capturedPre += (clazz -> qvar) capturedParams = qvar :: capturedParams qvar @@ -2586,7 +2595,7 @@ A type's typeSymbol should never be inspected directly. "something is wrong (wrong class file?): "+basesym+ " with type parameters "+ basesym.typeParams.map(_.name).mkString("[",",","]")+ - " gets applied to arguments "+baseargs.mkString("(",",",")")+", phase = "+phase) + " gets applied to arguments "+baseargs.mkString("[",",","]")+", phase = "+phase) instParam(basesym.typeParams, baseargs); case ExistentialType(tparams, qtpe) => capturedParams = capturedParams union tparams @@ -3180,7 +3189,14 @@ A type's typeSymbol should never be inspected directly. !(List.map3(args1, args2, sym1.typeParams) { (arg1, arg2, tparam) => //if (tparam.variance == 0 && !(arg1 =:= arg2)) Console.println("inconsistent: "+arg1+"!="+arg2)//DEBUG - tparam.variance != 0 || arg1 =:= arg2 + if (tparam.variance == 0) arg1 =:= arg2 + else if (arg1.isInstanceOf[TypeVar]) + // if left-hand argument is a typevar, make it compatible with variance + // this is for more precise pattern matching + // todo: work this in the spec of this method + // also: think what happens if there are embedded typevars? + if (tparam.variance < 0) arg1 <:< arg2 else arg2 <:< arg1 + else true } contains false) case (et: ExistentialType, _) => et.withTypeVars(isConsistent(_, tp2)) @@ -4090,7 +4106,7 @@ A type's typeSymbol should never be inspected directly. if (l <:< g) l else { val owner = commonOwner(as) - val qvar = makeExistential("", commonOwner(as), g, l) + val qvar = makeExistential("", commonOwner(as), mkTypeBounds(g, l)) capturedParams += qvar qvar.tpe } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index 06209194b7..13c666e122 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -470,11 +470,10 @@ abstract class ClassfileParser { case VOID_TAG => definitions.UnitClass.tpe case BOOL_TAG => definitions.BooleanClass.tpe case 'L' => { - val classSym = classNameToSymbol(subName(c => ((c == ';') || (c == '<')))) + val classSym = classNameToSymbol(subName(c => c == ';' || c == '<')) assert(!classSym.hasFlag(OVERLOADED), classSym.alternatives) val existentials = new ListBuffer[Symbol]() val tpe: Type = if (sig(index) == '<') { - assert(sym != null) accept('<') val xs = new ListBuffer[Type]() while (sig(index) != '>') { @@ -489,13 +488,11 @@ abstract class ClassfileParser { case '*' => mkTypeBounds(definitions.AllClass.tpe, definitions.AnyClass.tpe) } - val name = fresh.newName("T_" + sym.name) - val newtparam = sym.newTypeParameter(NoPosition, name) + val newtparam = makeExistential("", sym, bounds) existentials += newtparam - newtparam.setInfo(bounds) xs += newtparam.tpe - - case _ => xs += sig2type(tparams) + case _ => + xs += sig2type(tparams) } } accept('>') @@ -571,7 +568,7 @@ abstract class ClassfileParser { } ClassInfoType(parents.toList, instanceDefs, sym) } - parameterizedType(newTParams.toList, tpe) + polyType(newTParams.toList, tpe) } // polySigToType @@ -592,8 +589,8 @@ abstract class ClassfileParser { val sig = pool.getExternalName(in.nextChar) val newType = sigToType(sym, sig) sym.setInfo(newType) - if (settings.debug.value) - global.inform("" + sym + "; signatire = " + sig + " type = " + newType) +// if (settings.debug.value) + println("" + sym + "; signature = " + sig + " type = " + newType) hasMeta = true } else in.skip(attrLen) @@ -731,7 +728,8 @@ abstract class ClassfileParser { pool.getClassSymbol(outerIndex) == sym) { val innerAlias = getOwner(jflags) .newAliasType(NoPosition, pool.getName(nameIndex).toTypeName) - .setInfo(pool.getClassSymbol(innerIndex).tpe) + .setFlag(JAVA) + .setInfo(new LazyAliasType(pool.getClassSymbol(innerIndex))) getScope(jflags).enter(innerAlias) if ((jflags & JAVA_ACC_STATIC) != 0) { @@ -746,6 +744,14 @@ abstract class ClassfileParser { for (i <- 0 until attrCount) parseAttribute() } + class LazyAliasType(alias: Symbol) extends LazyType { + override def complete(sym: Symbol) { + alias.initialize + val tparams1 = cloneSymbols(alias.typeParams) + sym.setInfo(polyType(tparams1, alias.tpe.substSym(alias.typeParams, tparams1))) + } + } + def skipAttributes() { val attrCount = in.nextChar for (i <- 0 until attrCount) { diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index b285113ee6..1ae4eced0e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -522,7 +522,7 @@ trait Namers { self: Analyzer => } private def classSig(tparams: List[TypeDef], impl: Template): Type = - parameterizedType(typer.reenterTypeParams(tparams), templateSig(impl)) + polyType(typer.reenterTypeParams(tparams), templateSig(impl)) private def methodSig(tparams: List[TypeDef], vparamss: List[List[ValDef]], tpt: Tree, rhs: Tree): Type = { @@ -613,7 +613,7 @@ trait Namers { self: Analyzer => } def thisMethodType(restpe: Type) = - parameterizedType( + polyType( tparamSyms, if (vparamSymss.isEmpty) PolyType(List(), restpe) else checkDependencies((vparamSymss :\ restpe) (makeMethodType))) @@ -739,7 +739,7 @@ trait Namers { self: Analyzer => if (tpsym.owner.isRefinementClass && // only needed in refinements !tpsym.allOverriddenSymbols.forall{verifyOverriding(_)}) ErrorType - else parameterizedType(tparamSyms, tp) + else polyType(tparamSyms, tp) } def typeSig(tree: Tree): Type = { diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 2e3290c8d1..a42a7fbb6d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1890,7 +1890,7 @@ trait Typers { self: Analyzer => protected def existentialBound(sym: Symbol): Type = if (sym.isClass) - parameterizedType(sym.typeParams, mkTypeBounds(AllClass.tpe, sym.classBound)) + polyType(sym.typeParams, mkTypeBounds(AllClass.tpe, sym.classBound)) else if (sym.isAbstractType) sym.info else if (sym.isTerm) @@ -2340,7 +2340,7 @@ trait Typers { self: Analyzer => // of the type arguments as we don't know which alternative to choose... here we do val args1 = map2Conserve(args, tparams) { //@M! the polytype denotes the expected kind - (arg, tparam) => typedHigherKindedType(arg, parameterizedType(tparam.typeParams, AnyClass.tpe)) + (arg, tparam) => typedHigherKindedType(arg, polyType(tparam.typeParams, AnyClass.tpe)) } typedTypeApply(fun, args1) case SingleType(_, _) => @@ -2829,7 +2829,7 @@ trait Typers { self: Analyzer => // if symbol hasn't been fully loaded, can't check kind-arity else map2Conserve(args, tparams) { (arg, tparam) => - typedHigherKindedType(arg, parameterizedType(tparam.typeParams, AnyClass.tpe)) + typedHigherKindedType(arg, polyType(tparam.typeParams, AnyClass.tpe)) //@M! the polytype denotes the expected kind } val argtypes = args1 map (_.tpe) @@ -3020,7 +3020,7 @@ trait Typers { self: Analyzer => // @M maybe the well-kindedness check should be done when checking the type arguments conform to the type parameters' bounds? val args1 = if(args.length == tparams.length) map2Conserve(args, tparams) { //@M! the polytype denotes the expected kind - (arg, tparam) => typedHigherKindedType(arg, parameterizedType(tparam.typeParams, AnyClass.tpe)) + (arg, tparam) => typedHigherKindedType(arg, polyType(tparam.typeParams, AnyClass.tpe)) } else { //@M this branch is correctly hit for an overloaded polymorphic type. It also has to handle erroneous cases. // Until the right alternative for an overloaded method is known, be very liberal, diff --git a/src/dbc/scala/dbc/Vendor.scala b/src/dbc/scala/dbc/Vendor.scala index b9b3595d95..927d505b31 100644 --- a/src/dbc/scala/dbc/Vendor.scala +++ b/src/dbc/scala/dbc/Vendor.scala @@ -19,7 +19,7 @@ import java.sql.{Connection, Driver}; */ abstract class Vendor { - def nativeDriverClass: Class; + def nativeDriverClass: Class[Driver]; def uri: java.net.URI; def user: String; def pass: String; 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 */ diff --git a/test/files/run/classof.scala b/test/files/run/classof.scala index 3aa049ef68..b547e5c8c3 100644 --- a/test/files/run/classof.scala +++ b/test/files/run/classof.scala @@ -2,7 +2,7 @@ class SomeClass object Test { def main(args: Array[String]): Unit = { - val cls: Class = classOf[SomeClass] + val cls: Class[SomeClass] = classOf[SomeClass] Console.println(cls.getName()) } } |