diff options
author | Martin Odersky <odersky@gmail.com> | 2006-03-11 23:07:10 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2006-03-11 23:07:10 +0000 |
commit | 7cb7defbd4063d6c4cbd42a9222f51fe09346dab (patch) | |
tree | 799a8fddde6fa6a71e96d286fa13bbe98f7ab79f /src | |
parent | 74d770b456e0d907b35fae994ee4acb4a7fd3d63 (diff) | |
download | scala-7cb7defbd4063d6c4cbd42a9222f51fe09346dab.tar.gz scala-7cb7defbd4063d6c4cbd42a9222f51fe09346dab.tar.bz2 scala-7cb7defbd4063d6c4cbd42a9222f51fe09346dab.zip |
Bug fixes
Diffstat (limited to 'src')
7 files changed, 38 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 978bbf1da0..12c99ba127 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -87,6 +87,7 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable def error(msg: String) = reporter.error(null, msg); def warning(msg: String) = reporter.warning(null, msg); def inform(msg: String) = System.err.println(msg); + def inform[T](msg: String, value: T): T = { inform(msg+value); value } //reporter.info(null, msg, true); def informProgress(msg: String) = diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala index a327a0e053..111ef5f6e5 100644 --- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala +++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala @@ -751,9 +751,11 @@ trait Symbols requires SymbolTable { * Never translates expansions of operators back to operator symbol. * Never adds id. */ - final def fullNameString(separator: char): String = + final def fullNameString(separator: char): String = { + assert(owner != NoSymbol, this) if (owner.isRoot || owner.isEmptyPackageClass) simpleName.toString() else owner.fullNameString(separator) + separator + simpleName; + } final def fullNameString: String = fullNameString('.'); diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index 2ddb95018c..6ab9822d15 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -513,6 +513,10 @@ trait Types requires SymbolTable { else if (sym.isAnonymousClass || sym.isRefinementClass) "this." else if (sym.isPackageClass) sym.fullNameString + "." else sym.nameString + ".this."; + override def toString(): String = + if (sym.isRoot) "<root>" + else if (sym.isEmptyPackageClass) "<empty>" + else super.toString() override def narrow: Type = this; } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index 4b7fe373c2..d306d9a8ea 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -56,7 +56,7 @@ abstract class ClassfileParser { def parse(file: AbstractFile, root: Symbol): unit = { def handleError(e: Exception) = { if (settings.debug.value) e.printStackTrace();//debug - throw new IOException("class file '" + in.file + "' is broken") + throw new IOException("class file '" + in.file + "' is broken\n(" + e.getMessage() + ")") } assert(!busy); busy = true; diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala index 6746e165ec..7db3154d77 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala @@ -12,6 +12,7 @@ import java.lang.{Float, Double}; import Flags._; import PickleFormat._; import collection.mutable.HashMap; +import java.io.IOException; abstract class UnPickler { val global: Global; @@ -20,9 +21,10 @@ abstract class UnPickler { def unpickle(bytes: Array[byte], offset: int, classRoot: Symbol, moduleRoot: Symbol): unit = try { new UnPickle(bytes, offset, classRoot, moduleRoot); } catch { + case ex: IOException => + throw ex case ex: Throwable => - ex.printStackTrace();//debug - + if (settings.debug.value) ex.printStackTrace(); throw new RuntimeException("error reading Scala signature of " + classRoot.nameString + ": " + ex.getMessage()); } @@ -43,10 +45,10 @@ abstract class UnPickler { val major = readNat(); val minor = readNat(); if (major != MajorVersion || minor > MinorVersion) - throw new TypeError("Scala signature " + classRoot.name + - " has wrong version\n expected: " + - MajorVersion + "." + MinorVersion + - "\n found: " + major + "." + minor) + throw new IOException("Scala signature " + classRoot.name + + " has wrong version\n expected: " + + MajorVersion + "." + MinorVersion + + "\n found: " + major + "." + minor) } /** The scope associated with given symbol */ diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 4482480496..7d1b5a9c78 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -273,7 +273,8 @@ trait Typers requires Analyzer { if (tree.symbol.hasFlag(OVERLOADED) && (mode & FUNmode) == 0) inferExprAlternative(tree, pt) val sym = tree.symbol - if ((mode & (PATTERNmode | FUNmode)) == PATTERNmode && tree.isTerm) { // (1) + if (tree.tpe.isError) tree + else if ((mode & (PATTERNmode | FUNmode)) == PATTERNmode && tree.isTerm) { // (1) checkStable(tree) } else if ((mode & (EXPRmode | QUALmode)) == EXPRmode && !sym.isValue) { // (2) errorTree(tree, ""+sym+" is not a value") @@ -407,6 +408,8 @@ trait Typers requires Analyzer { case NoType => errorTree(tree, "expected pattern type "+pt + " does not conform to sequence "+clazz) + case ErrorType => + setError(tree) } } else { if (!tree.tpe.isError) @@ -552,7 +555,7 @@ trait Typers requires Analyzer { */ def validateParentClasses(parents: List[Tree], selfType: Type): unit = { - def validateParentClass(parent: Tree, superclazz: Symbol): unit = + def validateParentClass(parent: Tree, superclazz: Symbol): unit = { if (!parent.tpe.isError) { val psym = parent.tpe.symbol.initialize if (!psym.isClass) @@ -585,8 +588,10 @@ trait Typers requires Analyzer { if (parents exists (p => p != parent && p.tpe.symbol == psym && !psym.isError)) error(parent.pos, ""+psym+" is inherited twice") } + } - for (val p <- parents) validateParentClass(p, parents.head.tpe.symbol) + if (!parents.head.tpe.isError) + for (val p <- parents) validateParentClass(p, parents.head.tpe.symbol) } def typedClassDef(cdef: ClassDef): Tree = { @@ -1172,7 +1177,6 @@ trait Typers requires Analyzer { val tree1 = if (qual == EmptyTree) tree else atPos(tree.pos)(Select(qual, name)); // atPos necessary because qualifier might come from startContext - //System.out.println("check acc: "+defSym+" "+pre);//DEBUG stabilize(checkAccessible(tree1, defSym, pre, qual), pre, mode, pt) } diff --git a/src/library/scala/List.scala b/src/library/scala/List.scala index 824e109a60..a2ea568f38 100644 --- a/src/library/scala/List.scala +++ b/src/library/scala/List.scala @@ -415,6 +415,19 @@ sealed abstract class List[+a] extends Seq[a] { b.prependToList(this) } + /** Converts the list to an Array */ + def toArray[b >: a]: Array[b] = { + val xs = new Array[b](length) + var i = 0 + var these = this + while (!these.isEmpty) { + xs(i) = these.head + i = i + 1 + these = these.tail + } + xs + } + /** Reverse the given prefix and append the current list to that. * This function is equivalent to an application of <code>reverse</code> * on the prefix followed by a call to <code>:::</code>, but more |