summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2008-07-09 09:55:15 +0000
committerMartin Odersky <odersky@gmail.com>2008-07-09 09:55:15 +0000
commit323fe887df30250c96c9945e28c1be85441cdc7f (patch)
treeb7a6592179f0927df0ed2ed635d691e2d7330d47 /src
parent1133f0f05f0767ca2548cf49ef633b48f021e6e0 (diff)
downloadscala-323fe887df30250c96c9945e28c1be85441cdc7f.tar.gz
scala-323fe887df30250c96c9945e28c1be85441cdc7f.tar.bz2
scala-323fe887df30250c96c9945e28c1be85441cdc7f.zip
early initialization fixes.
fix: interface methods read by JavaParser are now deferred. fix: List extends Product. fixes to Java : _* that make it possible to compile ObjectRunner without warnings. NEW STARR
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala2
-rw-r--r--src/compiler/scala/tools/nsc/Interpreter.scala2
-rw-r--r--src/compiler/scala/tools/nsc/Settings.scala1
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeInfo.scala7
-rwxr-xr-xsrc/compiler/scala/tools/nsc/javac/JavaParsers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala6
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala50
-rw-r--r--src/library/scala/List.scala2
-rw-r--r--src/library/scala/concurrent/SyncVar.scala2
-rw-r--r--src/library/scala/io/BufferedSource.scala3
-rw-r--r--src/library/scala/xml/parsing/ConstructingParser.scala11
11 files changed, 48 insertions, 40 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index 5b5bc45d9f..fec56256fc 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -174,7 +174,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
try {
val clazz = Class.forName(settings.sourceReader.value)
val ccon = clazz.getConstructor(classOf[java.nio.charset.CharsetDecoder], classOf[Reporter])
- ccon.newInstance(charset.newDecoder(), reporter).asInstanceOf[SourceReader];
+ ccon.newInstance(charset.newDecoder(), reporter).asInstanceOf[SourceReader]
//new SourceReader(charset.newDecoder())
} catch {
case e =>
diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala
index d4bb362871..58412908ae 100644
--- a/src/compiler/scala/tools/nsc/Interpreter.scala
+++ b/src/compiler/scala/tools/nsc/Interpreter.scala
@@ -550,7 +550,7 @@ class Interpreter(val settings: Settings, out: PrintWriter) {
var argsHolder: Array[Any] = null // this roundabout approach is to try and
// make sure the value is boxed
argsHolder = List(value).toArray
- setterMethod.invoke(null, argsHolder.asInstanceOf[Array[AnyRef]] : _*)
+ setterMethod.invoke(null, argsHolder.asInstanceOf[Array[AnyRef]]: _*)
interpret("val " + name + " = " + binderName + ".value")
}
diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala
index ab9804d613..10c038badb 100644
--- a/src/compiler/scala/tools/nsc/Settings.scala
+++ b/src/compiler/scala/tools/nsc/Settings.scala
@@ -123,6 +123,7 @@ class Settings(error: String => Unit) {
val Xshowobj = StringSetting ("-Xshow-object", "object", "Show object info", "").hideToIDE
val showPhases = BooleanSetting ("-Xshow-phases", "Print a synopsis of compiler phases").hideToIDE
val sourceReader = StringSetting ("-Xsource-reader", "classname", "Specify a custom method for reading source files", "scala.tools.nsc.io.SourceReader").hideToIDE
+// val migrate2_7_2 = BooleanSetting ("-Xmigrate-to-2.7.2", "Issue warning messages to help in migration to 2.7.2")
val Yhelp = BooleanSetting ("-Y", "Print a synopsis of private options").hideToIDE
val browse = PhasesSetting ("-Ybrowse", "Browse the abstract syntax tree after")
diff --git a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala
index 48fdfe0f7f..76feeef0e2 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala
@@ -203,6 +203,13 @@ abstract class TreeInfo {
case _ => false
}
+ /** Is this argument node of the form <expr> : _* ?
+ */
+ def isWildcardStarArg(tree: Tree): Boolean = tree match {
+ case Typed(expr, Ident(name)) => name == nme.WILDCARD_STAR.toTypeName
+ case _ => false
+ }
+
/** Is this pattern node a catch-all (wildcard or variable) pattern? */
def isDefaultCase(cdef: CaseDef) = cdef match {
case CaseDef(Ident(nme.WILDCARD), EmptyTree, _) => true
diff --git a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
index 3d6c752128..72003d7b58 100755
--- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
+++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
@@ -483,7 +483,7 @@ trait JavaParsers extends JavaScanners {
def termDecl(mods: Modifiers, parentToken: Int): List[Tree] = {
val inInterface = parentToken == INTERFACE || parentToken == AT
var mods1 = mods
- if (mods hasFlag Flags.ABSTRACT) mods1 = mods &~ Flags.ABSTRACT | Flags.DEFERRED
+ if ((mods hasFlag Flags.ABSTRACT) || inInterface) mods1 = mods &~ Flags.ABSTRACT | Flags.DEFERRED
val tparams = if (in.token == LT) typeParams() else List()
val isVoid = in.token == VOID
var rtpt =
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index fbfae15b15..2444cbea22 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -2363,14 +2363,12 @@ A type's typeSymbol should never be inspected directly.
/** Map this function over given list of symbols */
def mapOver(origSyms: List[Symbol]): List[Symbol] = {
- var change = false
- val newInfos = for (sym <- origSyms) yield {
+ val change = origSyms exists { sym =>
val v = variance
if (sym.isAliasType) variance = 0
val result = this(sym.info)
- if (result ne sym.info) change = true
variance = v
- result
+ result ne sym.info
}
if (!change) origSyms // fast path in case nothing changes due to map
else { // map is not the identity --> do cloning properly
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 49dacac6bc..bb6d9c17bb 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1625,13 +1625,15 @@ trait Typers { self: Analyzer =>
!hasArrayElement(adaptedFormals(nonVarCount)) &&
!settings.XnoVarargsConversion.value) {
val lastarg = typedArg(args(nonVarCount), mode, REGPATmode, WildcardType)
- if (lastarg.tpe.typeSymbol == ArrayClass || lastarg.tpe.typeSymbol == AllRefClass) {
- unit.warning(
- lastarg.pos,
- "I'm seeing an array passed into a Java vararg.\n"+
- "I assume that the elements of this array should be passed as individual arguments to the vararg.\n"+
- "Therefore I wrap the array in a `: _*', to mark it as a vararg argument.\n"+
- "If that's not what you want, compile this file with option -Xno-varargs-conversion.")
+ if ((lastarg.tpe.typeSymbol == ArrayClass || lastarg.tpe.typeSymbol == AllRefClass) &&
+ !treeInfo.isWildcardStarArg(lastarg)) {
+ if (lastarg.tpe.typeSymbol == ArrayClass)
+ unit.warning(
+ lastarg.pos,
+ "I'm seeing an array passed into a Java vararg.\n"+
+ "I assume that the elements of this array should be passed as individual arguments to the vararg.\n"+
+ "Therefore I wrap the array in a `: _*', to mark it as a vararg argument.\n"+
+ "If that's not what you want, compile this file with option -Xno-varargs-conversion.")
args0 = args.init ::: List(gen.wildcardStar(args.last))
}
}
@@ -2062,6 +2064,7 @@ trait Typers { self: Analyzer =>
override def hashCode: Int = sym.hashCode * 41 + tp.hashCode
}
+ /** convert skolems to existentials */
def packedType(tree: Tree, owner: Symbol): Type = {
def defines(tree: Tree, sym: Symbol) =
sym.isExistentialSkolem && sym.unpackLocation == tree ||
@@ -3117,23 +3120,24 @@ trait Typers { self: Analyzer =>
case Typed(expr, Function(List(), EmptyTree)) =>
typedEta(checkDead(typed1(expr, mode, pt)))
- case Typed(expr, tpt @ Ident(name)) if (name == nme.WILDCARD_STAR.toTypeName) =>
- val expr1 = typed(expr, mode & stickyModes, seqType(pt))
- expr1.tpe.baseType(SeqClass) match {
- case TypeRef(_, _, List(elemtp)) =>
- copy.Typed(tree, expr1, tpt setType elemtp) setType elemtp
- case _ =>
- setError(tree)
- }
-
case Typed(expr, tpt) =>
- val tpt1 = typedType(tpt)
- val expr1 = typed(expr, mode & stickyModes, tpt1.tpe.deconst)
- val owntype =
- if ((mode & PATTERNmode) != 0) inferTypedPattern(tpt1.pos, tpt1.tpe, pt)
- else tpt1.tpe
- //Console.println(typed pattern: "+tree+":"+", tp = "+tpt1.tpe+", pt = "+pt+" ==> "+owntype)//DEBUG
- copy.Typed(tree, expr1, tpt1) setType owntype
+ if (treeInfo.isWildcardStarArg(tree)) {
+ val expr1 = typed(expr, mode & stickyModes, seqType(pt))
+ expr1.tpe.baseType(SeqClass) match {
+ case TypeRef(_, _, List(elemtp)) =>
+ copy.Typed(tree, expr1, tpt setType elemtp) setType elemtp
+ case _ =>
+ setError(tree)
+ }
+ } else {
+ val tpt1 = typedType(tpt)
+ val expr1 = typed(expr, mode & stickyModes, tpt1.tpe.deconst)
+ val owntype =
+ if ((mode & PATTERNmode) != 0) inferTypedPattern(tpt1.pos, tpt1.tpe, pt)
+ else tpt1.tpe
+ //Console.println(typed pattern: "+tree+":"+", tp = "+tpt1.tpe+", pt = "+pt+" ==> "+owntype)//DEBUG
+ copy.Typed(tree, expr1, tpt1) setType owntype
+ }
case TypeApply(fun, args) =>
// @M: kind-arity checking is done here and in adapt, full kind-checking is in checkKindBounds (in Infer)
diff --git a/src/library/scala/List.scala b/src/library/scala/List.scala
index 23667f68d7..287d552e34 100644
--- a/src/library/scala/List.scala
+++ b/src/library/scala/List.scala
@@ -442,7 +442,7 @@ object List {
* @author Martin Odersky and others
* @version 1.0, 16/07/2003
*/
-sealed abstract class List[+A] extends Seq[A] {
+sealed abstract class List[+A] extends Seq[A] with Product {
/** Returns true if the list does not contain any elements.
* @return <code>true</code>, iff the list is empty.
diff --git a/src/library/scala/concurrent/SyncVar.scala b/src/library/scala/concurrent/SyncVar.scala
index c04268990a..dfb619ca2a 100644
--- a/src/library/scala/concurrent/SyncVar.scala
+++ b/src/library/scala/concurrent/SyncVar.scala
@@ -52,7 +52,7 @@ class SyncVar[A] {
/**
* @deprecated Will be removed in 2.8. SyncVar should not allow exception by design.
*/
- def setWithCatch(x: => A) = synchronized {
+ @deprecated def setWithCatch(x: => A) = synchronized {
try {
this set x
} catch {
diff --git a/src/library/scala/io/BufferedSource.scala b/src/library/scala/io/BufferedSource.scala
index 99d8d036ae..aca7ea3943 100644
--- a/src/library/scala/io/BufferedSource.scala
+++ b/src/library/scala/io/BufferedSource.scala
@@ -29,8 +29,9 @@ object BufferedSource {
/** constructs a BufferedSource instance from an input stream, using given decoder */
def fromInputStream(inpStream: InputStream, decoder: CharsetDecoder, buffer_size: Int, do_reset: () => Source): BufferedSource = {
val byteChannel = Channels.newChannel(inpStream)
- return new BufferedSource(byteChannel, decoder) {
+ return new {
val buf_size = buffer_size
+ } with BufferedSource(byteChannel, decoder) {
override def reset = do_reset()
def close { inpStream.close }
}
diff --git a/src/library/scala/xml/parsing/ConstructingParser.scala b/src/library/scala/xml/parsing/ConstructingParser.scala
index 020b9892a0..adba52445d 100644
--- a/src/library/scala/xml/parsing/ConstructingParser.scala
+++ b/src/library/scala/xml/parsing/ConstructingParser.scala
@@ -53,15 +53,12 @@ object parseFromURL {
}
</pre>
*/
-class ConstructingParser(inp: Source, presWS:Boolean)
-extends { val input = inp }
-with ConstructingHandler
-with ExternalSources
-with MarkupParser {
+class ConstructingParser(val input: Source, val preserveWS: Boolean)
+extends ConstructingHandler
+with ExternalSources
+with MarkupParser {
// default impl. of Logged
override def log(msg: String): Unit = {}
-
- val preserveWS = presWS
}