From 422a46993cdb74ccf3650e0b171f65c6c12bdedf Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 19 Dec 2007 13:21:09 +0000 Subject: -target 1.5 now the default. --- src/actors/scala/actors/Actor.scala | 2 +- src/compiler/scala/tools/ant/Scalac.scala | 2 +- src/compiler/scala/tools/nsc/Interpreter.scala | 2 +- src/compiler/scala/tools/nsc/ObjectRunner.scala | 2 +- src/compiler/scala/tools/nsc/Settings.scala | 3 +- .../scala/tools/nsc/models/SemanticTokens.scala | 4 ++- src/compiler/scala/tools/nsc/plugins/Plugin.scala | 8 ++++-- .../nsc/symtab/classfile/ClassfileParser.scala | 4 +-- .../scala/tools/nsc/symtab/clr/CLRTypes.scala | 4 +-- .../scala/tools/nsc/typechecker/Typers.scala | 33 +++++++++++----------- src/dbc/scala/dbc/Vendor.scala | 2 +- .../scala/xml/include/sax/XIncludeFilter.scala | 4 +-- src/library/scala/xml/include/sax/XIncluder.scala | 2 +- test/files/jvm/typerep.check | 1 - test/files/jvm/typerep.scala | 12 ++++---- test/files/jvm5/annotations.scala | 2 +- test/files/neg/bug1010.check | 2 +- test/files/neg/bug608.check | 2 +- test/files/neg/sabin2.check | 2 +- test/files/neg/t0209.check | 2 +- test/files/run/streams.scala | 2 +- 21 files changed, 50 insertions(+), 47 deletions(-) diff --git a/src/actors/scala/actors/Actor.scala b/src/actors/scala/actors/Actor.scala index 5bde8948ca..6f796d0dac 100644 --- a/src/actors/scala/actors/Actor.scala +++ b/src/actors/scala/actors/Actor.scala @@ -24,7 +24,7 @@ import scala.compat.Platform */ object Actor { - private[actors] val tl = new ThreadLocal + private[actors] val tl = new ThreadLocal[Actor] /** * Returns the currently executing actor. Should be used instead diff --git a/src/compiler/scala/tools/ant/Scalac.scala b/src/compiler/scala/tools/ant/Scalac.scala index cee423f944..c840f571e5 100644 --- a/src/compiler/scala/tools/ant/Scalac.scala +++ b/src/compiler/scala/tools/ant/Scalac.scala @@ -555,7 +555,7 @@ class Scalac extends MatchingTask { if (!assemname.isEmpty) settings.assemname.value = assemname.get if (!assemrefs.isEmpty) settings.assemrefs.value = assemrefs.get - if (!generics.isEmpty) settings.Xgenerics.value = generics.get +// if (!generics.isEmpty) settings.Xgenerics.value = generics.get log("Scalac params = '" + addParams + "'", Project.MSG_DEBUG) var args = diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala index 6b7bd86104..3517c75132 100644 --- a/src/compiler/scala/tools/nsc/Interpreter.scala +++ b/src/compiler/scala/tools/nsc/Interpreter.scala @@ -776,7 +776,7 @@ class Interpreter(val settings: Settings, out: PrintWriter) { /** load and run the code using reflection */ def loadAndRun: (String, Boolean) = { - val interpreterResultObject: Class = + val interpreterResultObject: Class[_] = Class.forName(resultObjectName, true, classLoader) val resultValMethod: java.lang.reflect.Method = interpreterResultObject.getMethod("result", null) diff --git a/src/compiler/scala/tools/nsc/ObjectRunner.scala b/src/compiler/scala/tools/nsc/ObjectRunner.scala index f2fb6d6cd7..befdddef9b 100644 --- a/src/compiler/scala/tools/nsc/ObjectRunner.scala +++ b/src/compiler/scala/tools/nsc/ObjectRunner.scala @@ -23,7 +23,7 @@ object ObjectRunner { /** Look up a class with a given class path. */ private def findClass(loader: ClassLoader, objectName: String) - : Option[Class] = + : Option[Class[T] forSome { type T }] = { try { Some(Class.forName(objectName, true, loader)) diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala index d51c173149..ff45801767 100644 --- a/src/compiler/scala/tools/nsc/Settings.scala +++ b/src/compiler/scala/tools/nsc/Settings.scala @@ -94,7 +94,7 @@ class Settings(error: String => Unit) { val extdirs = StringSetting ("-extdirs", "dirs", "Override location of installed extensions", extdirsDefault) val outdir = StringSetting ("-d", "directory", "Specify where to place generated class files", ".") val encoding = StringSetting ("-encoding", "encoding", "Specify character encoding used by source files", encodingDefault) - val target = ChoiceSetting ("-target", "Specify for which target object files should be built", List("jvm-1.5", "jvm-1.4", "msil", "cldc"), "jvm-1.4") + val target = ChoiceSetting ("-target", "Specify for which target object files should be built", List("jvm-1.5", "jvm-1.4", "msil", "cldc"), "jvm-1.5") val printLate = BooleanSetting ("-print", "Print program with all Scala-specific features removed").hideToIDE val XO = BooleanSetting ("-optimise", "Generates faster bytecode by applying optimisations to the program") val explaintypes = BooleanSetting ("-explaintypes", "Explain type errors in more detail").hideToIDE @@ -136,7 +136,6 @@ class Settings(error: String => Unit) { val Xdce = BooleanSetting ("-Ydead-code", "Perform dead code elimination") val Xdetach = BooleanSetting ("-Ydetach", "Perform detaching of remote closures") val doc = BooleanSetting ("-Ydoc", "Generate documentation").hideToIDE - val Xgenerics = BooleanSetting ("-Ygenerics", "Use generic Java types") val inline = BooleanSetting ("-Yinline", "Perform inlining when possible") val Xlinearizer = ChoiceSetting ("-Ylinearizer", "Linearizer to use", List("normal", "dfs", "rpo", "dump"), "rpo") val log = PhasesSetting ("-Ylog", "Log operations in") diff --git a/src/compiler/scala/tools/nsc/models/SemanticTokens.scala b/src/compiler/scala/tools/nsc/models/SemanticTokens.scala index f8b6f26545..3cafc191e1 100644 --- a/src/compiler/scala/tools/nsc/models/SemanticTokens.scala +++ b/src/compiler/scala/tools/nsc/models/SemanticTokens.scala @@ -27,6 +27,8 @@ class SemanticTokens(val compiler: Global) { object ARG extends Kind object TPARAM extends Kind + type AnyClass = Class[_] + // static constants here abstract class Token { @@ -282,7 +284,7 @@ class SemanticTokens(val compiler: Global) { case tree : TypeTree => val treex = tree val tree1 = if (tree.original ne null) tree.original else tree - def classes(clazz: java.lang.Class): List[java.lang.Class] = + def classes(clazz: AnyClass): List[AnyClass] = if (clazz eq null) Nil else clazz :: classes(clazz.getSuperclass()) if (tree.original eq null) { diff --git a/src/compiler/scala/tools/nsc/plugins/Plugin.scala b/src/compiler/scala/tools/nsc/plugins/Plugin.scala index aa0a80e0aa..202e0ef26a 100644 --- a/src/compiler/scala/tools/nsc/plugins/Plugin.scala +++ b/src/compiler/scala/tools/nsc/plugins/Plugin.scala @@ -96,11 +96,13 @@ object Plugin { } } + type AnyClass = Class[_] + /** Loads a plugin class from the named jar file. Returns None * 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[AnyClass] = { val pluginInfo = loadDescription(jarfile).get try { @@ -120,7 +122,7 @@ object Plugin { */ def loadAllFrom(jars: List[File], dirs: List[File], - ignoring: List[String]): List[Class[_]] = + ignoring: List[String]): List[AnyClass] = { val alljars = new ListBuffer[File] @@ -143,7 +145,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: AnyClass, 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/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index 13c666e122..73b81107ee 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -585,11 +585,11 @@ abstract class ClassfileParser { val oldpb = in.bp attrName match { case nme.SignatureATTR => - if (global.settings.Xgenerics.value) { + if (global.settings.target.value == "jvm-1.5") { val sig = pool.getExternalName(in.nextChar) val newType = sigToType(sym, sig) sym.setInfo(newType) -// if (settings.debug.value) + if (settings.debug.value) println("" + sym + "; signature = " + sig + " type = " + newType) hasMeta = true } else diff --git a/src/compiler/scala/tools/nsc/symtab/clr/CLRTypes.scala b/src/compiler/scala/tools/nsc/symtab/clr/CLRTypes.scala index 0f83354b16..e312c61f3f 100644 --- a/src/compiler/scala/tools/nsc/symtab/clr/CLRTypes.scala +++ b/src/compiler/scala/tools/nsc/symtab/clr/CLRTypes.scala @@ -116,8 +116,8 @@ abstract class CLRTypes { alltypes = Array.concat(alltypes, atypes) } - val typeNameComparator: Comparator = - new Comparator() { + val typeNameComparator: Comparator[Any] = + new Comparator[Any]() { def compare(o1: Any, o2: Any): Int = { val t1 = o1.asInstanceOf[Type] val t2 = o2.asInstanceOf[Type] diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index a42a7fbb6d..4543111fba 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3341,22 +3341,23 @@ trait Typers { self: Analyzer => val tc = newTyper(context.makeImplicit(reportAmbiguous)) def ambiguousImplicitError(info1: ImplicitInfo, info2: ImplicitInfo, - pre1: String, pre2: String, trailer: String) = { - val coreMsg = - pre1+" "+info1.sym+info1.sym.locationString+" of type "+info1.tpe+"\n "+ - pre2+" "+info2.sym+info2.sym.locationString+" of type "+info2.tpe+"\n "+ - trailer - error(pos, - if (isView) { - val found = pt.typeArgs(0) - val req = pt.typeArgs(1) - typeErrorMsg(found, req)+ - "\nNote that implicit conversions are not applicable because they are ambiguous:\n "+ - coreMsg+"are possible conversion functions from "+ found+" to "+req - } else { - "ambiguous implicit values:\n "+coreMsg + "match expected type "+pt - }) - } + pre1: String, pre2: String, trailer: String) = + if (!info1.tpe.isErroneous && !info2.tpe.isErroneous) { + val coreMsg = + pre1+" "+info1.sym+info1.sym.locationString+" of type "+info1.tpe+"\n "+ + pre2+" "+info2.sym+info2.sym.locationString+" of type "+info2.tpe+"\n "+ + trailer + error(pos, + if (isView) { + val found = pt.typeArgs(0) + val req = pt.typeArgs(1) + typeErrorMsg(found, req)+ + "\nNote that implicit conversions are not applicable because they are ambiguous:\n "+ + coreMsg+"are possible conversion functions from "+ found+" to "+req + } else { + "ambiguous implicit values:\n "+coreMsg + "match expected type "+pt + }) + } /** Search list of implicit info lists for one matching prototype * pt. If found return a tree from found implicit info diff --git a/src/dbc/scala/dbc/Vendor.scala b/src/dbc/scala/dbc/Vendor.scala index 927d505b31..c26f204b2a 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[Driver]; + def nativeDriverClass: Class[_]; def uri: java.net.URI; def user: String; def pass: String; diff --git a/src/library/scala/xml/include/sax/XIncludeFilter.scala b/src/library/scala/xml/include/sax/XIncludeFilter.scala index 7a0bcfe1fc..19dc5ecead 100644 --- a/src/library/scala/xml/include/sax/XIncludeFilter.scala +++ b/src/library/scala/xml/include/sax/XIncludeFilter.scala @@ -96,8 +96,8 @@ class XIncludeFilter extends XMLFilterImpl { final val XINCLUDE_NAMESPACE = "http://www.w3.org/2001/XInclude"; - private val bases = new Stack(); - private val locators = new Stack(); + private val bases = new Stack[URL](); + private val locators = new Stack[Locator](); /* private EntityResolver resolver; diff --git a/src/library/scala/xml/include/sax/XIncluder.scala b/src/library/scala/xml/include/sax/XIncluder.scala index 79c1807fb9..bac9c9d82e 100644 --- a/src/library/scala/xml/include/sax/XIncluder.scala +++ b/src/library/scala/xml/include/sax/XIncluder.scala @@ -146,7 +146,7 @@ with ContentHandler with LexicalHandler { // LexicalHandler methods private var inDTD: Boolean = false - private val entities: Stack = new Stack() + private val entities = new Stack[String]() def startDTD(name: String, publicID: String, systemID: String) { inDTD = true diff --git a/test/files/jvm/typerep.check b/test/files/jvm/typerep.check index 410654627f..ff98348304 100644 --- a/test/files/jvm/typerep.check +++ b/test/files/jvm/typerep.check @@ -9,7 +9,6 @@ Float Double String Unit -Class Some[Int] Some[Int] diff --git a/test/files/jvm/typerep.scala b/test/files/jvm/typerep.scala index f0aac8e935..b133d7ce99 100644 --- a/test/files/jvm/typerep.scala +++ b/test/files/jvm/typerep.scala @@ -17,6 +17,7 @@ object Test extends Application { object serialize { import java.io._ + @throws(classOf[IOException]) def write[A](o: A): Array[Byte] = { val ba = new ByteArrayOutputStream(512) @@ -48,7 +49,7 @@ object testPrimitives { println(getType(0.0d)) println(getType("abc")) println(getType(())) // Unit - println(getType(classOf[Int])) // Class +// println(getType(classOf[Int])) // Class println } @@ -172,9 +173,8 @@ object TypeRep { implicit def floatRep: TypeRep[Float] = FloatRep implicit def doubleRep: TypeRep[Double] = DoubleRep - type AnyClass = Class[_] implicit def unitRep: TypeRep[Unit] = UnitRep - implicit def classRep: TypeRep[AnyClass] = ClassRep +// implicit def classRep: TypeRep[Class] = ClassRep implicit def stringRep: TypeRep[String] = StringRep implicit def noneRep: TypeRep[Option[Nothing]] = NoneRep[Nothing](NothingRep.asInstanceOf[TypeRep[Nothing]]) implicit def anyRep: TypeRep[Any] = AnyRep @@ -257,9 +257,9 @@ object TypeRep { case object UnitRep extends TypeRep[Unit] { override def toString = "Unit" } - case object ClassRep extends TypeRep[AnyClass] { - override def toString = "Class" - } +// case object ClassRep extends TypeRep[AnyClass] { +// override def toString = "Class" +// } case object StringRep extends TypeRep[String] { override def toString = "String" } diff --git a/test/files/jvm5/annotations.scala b/test/files/jvm5/annotations.scala index 107bebbee7..98b82edad4 100644 --- a/test/files/jvm5/annotations.scala +++ b/test/files/jvm5/annotations.scala @@ -133,7 +133,7 @@ object Test5 { private var count: Integer = 0 private val getter = - getClass().getMethod("getCount", Array[java.lang.Class]()) + getClass().getMethod("getCount", Array[java.lang.Class[T] forSome { type T }]()) private val setter = getClass().getMethod("setCount", Array(classOf[Integer])) diff --git a/test/files/neg/bug1010.check b/test/files/neg/bug1010.check index 3cf9738eaa..35390aa88a 100644 --- a/test/files/neg/bug1010.check +++ b/test/files/neg/bug1010.check @@ -1,6 +1,6 @@ bug1010.scala:14: error: type mismatch; found : MailBox#Message - required: _3.in.Message where val _3: Actor + required: _16.in.Message where val _16: Actor unstable.send(msg) // in.Message becomes unstable.Message, but that's ok since Message is a concrete type member ^ one error found diff --git a/test/files/neg/bug608.check b/test/files/neg/bug608.check index 8337c513ff..e0acf6fa0f 100644 --- a/test/files/neg/bug608.check +++ b/test/files/neg/bug608.check @@ -1,6 +1,6 @@ bug608.scala:16: error: type mismatch; found : (a) => a - required: (_1.a) => ? where val _1: hs{type s = hs; type a = ha} + required: (_14.a) => ? where val _14: hs{type s = hs; type a = ha} = g(f(x).bimap(id)) ^ one error found diff --git a/test/files/neg/sabin2.check b/test/files/neg/sabin2.check index 92578bc23e..070b03a54b 100644 --- a/test/files/neg/sabin2.check +++ b/test/files/neg/sabin2.check @@ -1,6 +1,6 @@ sabin2.scala:22: error: type mismatch; found : Test.Base#T - required: _7.T where val _7: Test.Base + required: _20.T where val _20: Test.Base a.set(b.get()) // Error ^ one error found diff --git a/test/files/neg/t0209.check b/test/files/neg/t0209.check index 38b911533f..19e06d10b9 100644 --- a/test/files/neg/t0209.check +++ b/test/files/neg/t0209.check @@ -1,6 +1,6 @@ t0209.scala:15: error: type mismatch; found : C - required: _1 where val _1: A + required: _14 where val _14: A (new B: A).f(new C) ^ one error found diff --git a/test/files/run/streams.scala b/test/files/run/streams.scala index 5f61cb11af..1e781a6171 100644 --- a/test/files/run/streams.scala +++ b/test/files/run/streams.scala @@ -22,7 +22,7 @@ object Test extends Application { println(s2.dropWhile(_ > 0)) println - val s3 = Stream.range(1, 10000) //100000 (ticket #153: Stackoverflow) + val s3 = Stream.range(1, 1000) //100000 (ticket #153: Stackoverflow) println(s3.length) // ticket #153 -- cgit v1.2.3