summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2006-10-13 19:06:41 +0000
committermichelou <michelou@epfl.ch>2006-10-13 19:06:41 +0000
commitaf511469a6c4323488e1e263cc2f45786f276672 (patch)
tree507ccb0fee6fe1c1b7ef9ea2955c8b3d4d7bbbbe
parentec04190880e49b0d32651fe04e27a67bd952bcdd (diff)
downloadscala-af511469a6c4323488e1e263cc2f45786f276672.tar.gz
scala-af511469a6c4323488e1e263cc2f45786f276672.tar.bz2
scala-af511469a6c4323488e1e263cc2f45786f276672.zip
changed "All/AllRef" to "Nothing/Null" in test/...
changed "All/AllRef" to "Nothing/Null" in test/library/compiler
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala139
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Definitions.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/StdNames.scala2
-rw-r--r--src/compiler/scala/tools/nsc/util/ClassPath.scala5
-rw-r--r--src/library/scala/All$.scala1
-rw-r--r--src/library/scala/AllRef$.scala1
-rw-r--r--src/library/scala/List.scala6
-rw-r--r--src/library/scala/Nothing$.scala21
-rw-r--r--src/library/scala/Null$.scala21
-rw-r--r--src/library/scala/Predef.scala6
-rw-r--r--src/library/scala/collection/immutable/Queue.scala4
-rw-r--r--test/files/neg/viewtest.check2
-rw-r--r--test/files/neg/viewtest.scala64
-rw-r--r--test/files/pos/infer.scala14
-rw-r--r--test/files/pos/patterns.scala18
-rw-r--r--test/files/pos/patterns1.scala16
-rw-r--r--test/files/pos/simplelists.scala29
-rw-r--r--test/files/pos/viewtest1.scala2
-rw-r--r--test/files/pos/viewtest2.scala6
19 files changed, 210 insertions, 149 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
index a6125c4a95..6bb0a4eb9b 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
@@ -97,6 +97,10 @@ abstract class GenJVM extends SubComponent {
val emitLines = settings.debuginfo.level >= 2
val emitVars = settings.debuginfo.level >= 3
+ /**
+ * @param jclass ...
+ * @param sym ...
+ */
def emitClass(jclass: JClass, sym: Symbol): Unit = {
def addScalaAttr(sym: Symbol): Unit = currentRun.symData.get(sym) match {
case Some(pickle) =>
@@ -115,14 +119,14 @@ abstract class GenJVM extends SubComponent {
}
if (!(jclass.getName().endsWith("$") && sym.isModuleClass))
addScalaAttr(if (isTopLevelModule(sym)) sym.sourceModule else sym);
- addInnerClasses;
+ addInnerClasses
val outfile = getFile(jclass, ".class")
jclass.writeTo(outfile)
val file = scala.tools.nsc.io.AbstractFile.getFile(outfile)
informProgress("wrote " + outfile + " " +
(if (file != null) "" + file.file + " " + file.file.exists()
- else "no file"));
+ else "no file"))
}
var serialVUID: Option[Long] = None
@@ -155,14 +159,14 @@ abstract class GenJVM extends SubComponent {
case Triple(RemoteAttr, _, _) =>
parents = parents ::: List(RemoteInterface.tpe)
remoteClass = true
- case _ => ();
+ case _ => ()
}
parents = parents.removeDuplicates
if (parents.length > 1) {
ifaces = new Array[String](parents.length - 1)
- parents.drop(1).map((s) => javaName(s.symbol)).copyToArray(ifaces, 0);
+ parents.drop(1).map((s) => javaName(s.symbol)).copyToArray(ifaces, 0)
()
}
@@ -175,17 +179,19 @@ abstract class GenJVM extends SubComponent {
if (isStaticModule(c.symbol) || serialVUID != None) {
if (isStaticModule(c.symbol))
addModuleInstanceField;
- addStaticInit(jclass);
+ addStaticInit(jclass)
if (isTopLevelModule(c.symbol)) {
if (c.symbol.linkedClassOfModule == NoSymbol)
dumpMirrorClass;
else if (c.symbol.linkedClassOfModule != NoSymbol &&
!currentRun.compiles(c.symbol.linkedClassOfModule)) {
- log("Dumping mirror class for " + c.symbol + " even though linked class exists, but is not compiled in this run");
- dumpMirrorClass;
+ log("Dumping mirror class for " + c.symbol + " even though " +
+ "linked class exists, but is not compiled in this run")
+ dumpMirrorClass
} else
- log("No mirror class for module with linked class: " + c.symbol.fullNameString);
+ log("No mirror class for module with linked class: " +
+ c.symbol.fullNameString)
}
}
@@ -201,7 +207,7 @@ abstract class GenJVM extends SubComponent {
val Pair(excs, others) = sym.attributes.partition((a => a match {
case Triple(ThrowsAttr, _, _) => true
case _ => false
- }));
+ }))
if (excs isEmpty) return;
sym.attributes = others
@@ -223,7 +229,7 @@ abstract class GenJVM extends SubComponent {
}
private def emitAttributes(buf: ByteBuffer, attributes: List[AttrInfo]): Int = {
- val cpool = jclass.getConstantPool();
+ val cpool = jclass.getConstantPool()
def emitElement(const: Constant): Unit = const.tag match {
case BooleanTag =>
@@ -295,9 +301,9 @@ abstract class GenJVM extends SubComponent {
}
def addAnnotations(jmember: JMember, attributes: List[AttrInfo]): Unit = {
- if (attributes.isEmpty) return;
+ if (attributes.isEmpty) return
- val buf: ByteBuffer = ByteBuffer.allocate(2048);
+ val buf: ByteBuffer = ByteBuffer.allocate(2048)
emitAttributes(buf, attributes)
@@ -310,7 +316,7 @@ abstract class GenJVM extends SubComponent {
tpe.symbol hasFlag Flags.JAVA) yield attr;
if (attributes.forall(.isEmpty)) return;
- val buf: ByteBuffer = ByteBuffer.allocate(2048);
+ val buf: ByteBuffer = ByteBuffer.allocate(2048)
// number of parameters
buf.put(attributes.length.toByte)
@@ -381,7 +387,8 @@ abstract class GenJVM extends SubComponent {
def genMethod(m: IMethod): Unit = {
if (settings.debug.value)
- log("Generating method " + m.symbol + " flags: " + Flags.flagsToString(m.symbol.flags) +
+ log("Generating method " + m.symbol +
+ " flags: " + Flags.flagsToString(m.symbol.flags) +
" owner: " + m.symbol.owner);
method = m
endPC.clear
@@ -403,7 +410,7 @@ abstract class GenJVM extends SubComponent {
if (m.symbol.hasFlag(Flags.BRIDGE))
jmethod.addAttribute(fjbgContext.JOtherAttribute(jclass, jmethod, "Bridge",
- new Array[Byte](0)));
+ new Array[Byte](0)))
if ((remoteClass ||
(m.symbol.attributes contains Triple(RemoteAttr, Nil, Nil))) &&
jmethod.isPublic() && !forCLDC)
@@ -417,25 +424,26 @@ abstract class GenJVM extends SubComponent {
// add a fake local for debugging purpuses
if (emitVars && isClosureApply(method.symbol)) {
- val outerField = clasz.symbol.info.decl(nme.getterToLocal(nme.OUTER));
+ val outerField = clasz.symbol.info.decl(nme.getterToLocal(nme.OUTER))
if (outerField != NoSymbol) {
- log("Adding fake local to represent outer 'this' for closure " + clasz);
- val _this = new Local(method.symbol.newVariable(NoPos, "this$"), toTypeKind(outerField.tpe), false);
- m.locals = m.locals ::: List(_this);
+ log("Adding fake local to represent outer 'this' for closure " + clasz)
+ val _this = new Local(
+ method.symbol.newVariable(NoPos, "this$"), toTypeKind(outerField.tpe), false)
+ m.locals = m.locals ::: List(_this)
computeLocalVarsIndex(m) // since we added a new local, we need to recompute indexes
- jcode.emitALOAD_0;
+ jcode.emitALOAD_0
jcode.emitGETFIELD(javaName(clasz.symbol),
javaName(outerField),
- javaType(outerField));
- jcode.emitSTORE(indexOf(_this), javaType(_this.kind));
+ javaType(outerField))
+ jcode.emitSTORE(indexOf(_this), javaType(_this.kind))
}
}
for (val local <- m.locals; (! m.params.contains(local))) {
if (settings.debug.value)
log("add local var: " + local);
- jmethod.addNewLocalVariable(javaType(local.kind), javaName(local.sym));
+ jmethod.addNewLocalVariable(javaType(local.kind), javaName(local.sym))
}
genCode(m)
@@ -488,7 +496,7 @@ abstract class GenJVM extends SubComponent {
JType.LONG)
clinit.emitPUSH(value)
clinit.emitPUTSTATIC(jclass.getName(), fieldName, JType.LONG)
- case None => ();
+ case None => ()
}
clinit.emitRETURN()
@@ -524,19 +532,19 @@ abstract class GenJVM extends SubComponent {
mirrorCode.emitGETSTATIC(moduleName,
MODULE_INSTANCE_NAME,
new JObjectType(moduleName));
- var i = 0;
- var index = 0;
- var argTypes = mirrorMethod.getArgumentTypes();
+ var i = 0
+ var index = 0
+ var argTypes = mirrorMethod.getArgumentTypes()
while (i < argTypes.length) {
mirrorCode.emitLOAD(index, argTypes(i))
index = index + argTypes(i).getSize()
i = i + 1
}
- mirrorCode.emitINVOKEVIRTUAL(moduleName, mirrorMethod.getName(), mirrorMethod.getType().asInstanceOf[JMethodType]);
- mirrorCode.emitRETURN(mirrorMethod.getReturnType());
+ mirrorCode.emitINVOKEVIRTUAL(moduleName, mirrorMethod.getName(), mirrorMethod.getType().asInstanceOf[JMethodType])
+ mirrorCode.emitRETURN(mirrorMethod.getReturnType())
}
- emitClass(mirrorClass, clasz.symbol);
+ emitClass(mirrorClass, clasz.symbol)
}
var linearization: List[BasicBlock] = Nil
@@ -562,7 +570,7 @@ abstract class GenJVM extends SubComponent {
var nextBlock: BasicBlock = _
def genBlocks(l: List[BasicBlock]): Unit = l match {
- case Nil => ();
+ case Nil => ()
case x :: Nil => nextBlock = null; genBlock(x)
case x :: y :: ys => nextBlock = y; genBlock(x); genBlocks(y :: ys)
}
@@ -656,7 +664,7 @@ abstract class GenJVM extends SubComponent {
instr match {
case THIS(clasz) =>
- jcode.emitALOAD_0();
+ jcode.emitALOAD_0()
case CONSTANT(const) =>
const.tag match {
@@ -695,18 +703,19 @@ abstract class GenJVM extends SubComponent {
var owner = javaName(field.owner);
// if (field.owner.hasFlag(Flags.MODULE)) owner = owner + "$";
if (settings.debug.value)
- log("LOAD_FIELD with owner: " + owner + " flags: " + Flags.flagsToString(field.owner.flags));
+ log("LOAD_FIELD with owner: " + owner +
+ " flags: " + Flags.flagsToString(field.owner.flags))
if (isStatic)
jcode.emitGETSTATIC(owner,
javaName(field),
- javaType(field));
+ javaType(field))
else
jcode.emitGETFIELD(owner,
javaName(field),
- javaType(field));
+ javaType(field))
case LOAD_MODULE(module) =>
- assert(module.isModule || module.isModuleClass, "Expected module: " + module);
+ assert(module.isModule || module.isModuleClass, "Expected module: " + module)
if (settings.debug.value)
log("genearting LOAD_MODULE for: " + module + " flags: " +
Flags.flagsToString(module.flags));
@@ -715,29 +724,31 @@ abstract class GenJVM extends SubComponent {
javaType(module));
case STORE_ARRAY_ITEM(kind) =>
- jcode.emitASTORE(javaType(kind));
+ jcode.emitASTORE(javaType(kind))
case STORE_LOCAL(local) =>
- jcode.emitSTORE(indexOf(local), javaType(local.kind));
+ jcode.emitSTORE(indexOf(local), javaType(local.kind))
case STORE_FIELD(field, isStatic) =>
- val owner = javaName(field.owner); // + (if (field.owner.hasFlag(Flags.MODULE)) "$" else "");
+ val owner = javaName(field.owner) // + (if (field.owner.hasFlag(Flags.MODULE)) "$" else "");
if (isStatic)
jcode.emitPUTSTATIC(owner,
javaName(field),
- javaType(field));
+ javaType(field))
else
jcode.emitPUTFIELD(owner,
javaName(field),
- javaType(field));
+ javaType(field))
case CALL_PRIMITIVE(primitive) =>
- genPrimitive(primitive, instr.pos);
+ genPrimitive(primitive, instr.pos)
case call @ CALL_METHOD(method, style) =>
val owner: String = javaName(method.owner);
//reference the type of the receiver instead of the method owner (if not an interface!)
- val dynamicOwner = if (needsInterfaceCall(call.hostClass)) owner else javaName(call.hostClass);
+ val dynamicOwner =
+ if (needsInterfaceCall(call.hostClass)) owner
+ else javaName(call.hostClass)
style match {
case Dynamic =>
@@ -1193,7 +1204,7 @@ abstract class GenJVM extends SubComponent {
for (val l <- m.locals) {
if (settings.debug.value)
- log("Index value for " + l + "{" + l.hashCode + "}: " + idx);
+ log("Index value for " + l + "{" + l.hashCode + "}: " + idx)
l.index = idx
idx = idx + sizeOf(l.kind)
}
@@ -1201,16 +1212,22 @@ abstract class GenJVM extends SubComponent {
////////////////////// Utilities ////////////////////////
- /** Return the a name of this symbol that can be used on the Java
- * platform. It removes spaces from names.
- *
- * Special handling: scala.All and scala.AllRef are 'erased' to
- * scala.All$ and scala.AllRef$. This is needed because they are
- * not real classes, and they mean 'abrupt termination upon evaluation
- * of that expression' or 'null' respectively. This handling is
- * done already in GenICode, but here we need to remove references
- * from method signatures to these types, because such classes can
- * not exist in the classpath: the type checker will be very confused.
+ /**
+ * <p>
+ * Return the a name of this symbol that can be used on the Java
+ * platform. It removes spaces from names.
+ * </p>
+ * <p>
+ * Special handling: scala.Nothing and <code>scala.Null</code> are
+ * <em>erased</em> to <code>scala.Nothing$</code> and
+ * </code>scala.Null$</code>. This is needed because they are
+ * not real classes, and they mean 'abrupt termination upon evaluation
+ * of that expression' or <code>null</code> respectively. This handling is
+ * done already in <a href="../icode/GenIcode.html" target="contentFrame">
+ * <code>GenICode</code></a>, but here we need to remove references
+ * from method signatures to these types, because such classes can
+ * not exist in the classpath: the type checker will be very confused.
+ * </p>
*/
def javaName(sym: Symbol): String = {
val suffix = if (sym.hasFlag(Flags.MODULE) && !sym.isMethod &&
@@ -1218,9 +1235,9 @@ abstract class GenJVM extends SubComponent {
!sym.hasFlag(Flags.JAVA)) "$" else "";
if (sym == definitions.AllClass)
- return "scala.All$"
+ return "scala.Nothing$"
else if (sym == definitions.AllRefClass)
- return "scala.AllRef$";
+ return "scala.Null$"
if (sym.isClass && !sym.rawowner.isPackageClass)
innerClasses = innerClasses + sym;
@@ -1261,7 +1278,7 @@ abstract class GenJVM extends SubComponent {
val f = sym.flags
jf = jf | (if (sym hasFlag Flags.SYNTHETIC) ACC_SYNTHETIC else 0)
/* jf = jf | (if (sym hasFlag Flags.PRIVATE) ACC_PRIVATE else
- if (sym hasFlag Flags.PROTECTED) ACC_PROTECTED else ACC_PUBLIC);
+ if (sym hasFlag Flags.PROTECTED) ACC_PROTECTED else ACC_PUBLIC)
*/
jf = jf | (if (sym hasFlag Flags.PRIVATE) ACC_PRIVATE else ACC_PUBLIC)
jf = jf | (if ((sym hasFlag Flags.ABSTRACT) ||
@@ -1304,7 +1321,7 @@ abstract class GenJVM extends SubComponent {
if (s.isClassConstructor) JType.VOID else javaType(s.tpe.resultType),
s.tpe.paramTypes.map(javaType).toArray)
else
- javaType(s.tpe);
+ javaType(s.tpe)
def javaTypes(ts: List[TypeKind]): Array[JType] = {
val res = new Array[JType](ts.length)
@@ -1329,9 +1346,9 @@ abstract class GenJVM extends SubComponent {
val pool = jclass.getConstantPool()
val pc = jcode.getPC()
var anonCounter = 0
- val locals = if (jmethod.isStatic()) vars.length else 1 + vars.length;
+ val locals = if (jmethod.isStatic()) vars.length else 1 + vars.length
- val lvTab = ByteBuffer.allocate(2 + 10 * locals);
+ val lvTab = ByteBuffer.allocate(2 + 10 * locals)
def emitEntry(name: String, signature: String, idx: Short): Unit = {
lvTab.putShort(0.asInstanceOf[Short])
lvTab.putShort(pc.asInstanceOf[Short])
@@ -1348,7 +1365,7 @@ abstract class GenJVM extends SubComponent {
for (val lv <- vars) {
val name = if (javaName(lv.sym) eq null) {
- anonCounter = anonCounter + 1;
+ anonCounter = anonCounter + 1
"<anon" + anonCounter + ">"
} else javaName(lv.sym)
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
index 70b6ec051a..71fe01063a 100644
--- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
@@ -477,11 +477,9 @@ trait Definitions requires SymbolTable {
AllRefClass = newClass(ScalaPackageClass, nme.Null, anyrefparam)
.setFlag(ABSTRACT | TRAIT | FINAL)
- val oldAllRefClass = newAlias(ScalaPackageClass, nme.AllRef, AllRefClass.typeConstructor)
AllClass = newClass(ScalaPackageClass, nme.Nothing, anyparam)
.setFlag(ABSTRACT | TRAIT | FINAL)
- val oldAllClass = newAlias(ScalaPackageClass, nme.All, AllClass.typeConstructor)
ClassClass = getClass("java.lang.Class")
StringClass = getClass("java.lang.String")
diff --git a/src/compiler/scala/tools/nsc/symtab/StdNames.scala b/src/compiler/scala/tools/nsc/symtab/StdNames.scala
index 830a6b5150..2aafcdbd48 100644
--- a/src/compiler/scala/tools/nsc/symtab/StdNames.scala
+++ b/src/compiler/scala/tools/nsc/symtab/StdNames.scala
@@ -175,8 +175,6 @@ trait StdNames requires SymbolTable {
val Nothing = newTermName("Nothing")
val Null = newTermName("Null")
- val All = newTermName("All")
- val AllRef = newTermName("AllRef")
val Any = newTermName("Any")
val AnyVal = newTermName("AnyVal")
val AnyRef = newTermName("AnyRef")
diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala
index b2aee983a2..bf44bdcae1 100644
--- a/src/compiler/scala/tools/nsc/util/ClassPath.scala
+++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala
@@ -194,6 +194,11 @@ class ClassPath(onlyPresentation: Boolean) {
addFilesInPath(classpath)
}
+ /**
+ * @param path ...
+ * @param isDir ...
+ * @return ...
+ */
def lookupPath(path: String, isDir: Boolean) = {
val ctx = root.find(path, isDir)
if (ctx == null) null
diff --git a/src/library/scala/All$.scala b/src/library/scala/All$.scala
index 70b52d8ef1..6c71dd5ce6 100644
--- a/src/library/scala/All$.scala
+++ b/src/library/scala/All$.scala
@@ -18,4 +18,5 @@ package scala
* signatures, it is erased to this one.
*/
+/** to be removed after new starr */
sealed abstract class All$
diff --git a/src/library/scala/AllRef$.scala b/src/library/scala/AllRef$.scala
index 919b4983a3..f45de212ff 100644
--- a/src/library/scala/AllRef$.scala
+++ b/src/library/scala/AllRef$.scala
@@ -18,4 +18,5 @@ package scala
* signatures, it is erased to this one.
*/
+/** to be removed after new starr */
sealed abstract class AllRef$
diff --git a/src/library/scala/List.scala b/src/library/scala/List.scala
index c0b5aedd88..6b2c0ef1cf 100644
--- a/src/library/scala/List.scala
+++ b/src/library/scala/List.scala
@@ -1093,11 +1093,13 @@ case object Nil extends List[Nothing] {
/**
* @throws java.util.NoSuchElementException
*/
- def head: All = throw new java.util.NoSuchElementException("head of empty list")
+ def head: Nothing =
+ throw new java.util.NoSuchElementException("head of empty list")
/**
* @throws java.util.NoSuchElementException
*/
- def tail: List[Nothing] = throw new java.util.NoSuchElementException("tail of empty list")
+ def tail: List[Nothing] =
+ throw new java.util.NoSuchElementException("tail of empty list")
}
/** A non empty list characterized by a head and a tail.
diff --git a/src/library/scala/Nothing$.scala b/src/library/scala/Nothing$.scala
new file mode 100644
index 0000000000..51a16361e9
--- /dev/null
+++ b/src/library/scala/Nothing$.scala
@@ -0,0 +1,21 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id: $
+
+
+package scala
+
+
+/**
+ * Dummy class which exist only to satisfy the JVM. It corresponds
+ * to <code>scala.Nothing</code>. If such type appears in method
+ * signatures, it is erased to this one.
+ */
+
+sealed abstract class Nothing$
diff --git a/src/library/scala/Null$.scala b/src/library/scala/Null$.scala
new file mode 100644
index 0000000000..6ede96473f
--- /dev/null
+++ b/src/library/scala/Null$.scala
@@ -0,0 +1,21 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id: $
+
+
+package scala
+
+
+/**
+ * Dummy class which exist only to satisfy the JVM. It corresponds
+ * to <code>scala.Null</code>. If such type appears in method
+ * signatures, it is erased to this one.
+ */
+
+sealed abstract class Null$
diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala
index 25faa0ff35..b0206ae9f5 100644
--- a/src/library/scala/Predef.scala
+++ b/src/library/scala/Predef.scala
@@ -25,12 +25,6 @@ object Predef {
// aliases -------------------------------------------------------
- /** to be removed after new starr */
- type Nothing = All
-
- /** to be removed after new starr */
- type Null = AllRef
-
type byte = scala.Byte
type short = scala.Short
type char = scala.Char
diff --git a/src/library/scala/collection/immutable/Queue.scala b/src/library/scala/collection/immutable/Queue.scala
index 27bfdd4c32..88cf3d7016 100644
--- a/src/library/scala/collection/immutable/Queue.scala
+++ b/src/library/scala/collection/immutable/Queue.scala
@@ -13,7 +13,7 @@ package scala.collection.immutable
object Queue {
- val Empty: Queue[All] = new Queue()
+ val Empty: Queue[Nothing] = new Queue()
}
/** <code>Queue</code> objects implement data structures that allow to
@@ -41,7 +41,7 @@ class Queue[+A](elem: A*) extends Seq[A] {
*
* @param n index of the element to return
* @return the element at position <code>n</code> in this queue.
- * @throws <code>java.util.NoSuchElementException</code> if the queue is too short.
+ * @throws java.util.NoSuchElementException if the queue is too short.
*/
def apply(n: Int): A = {
val len = out.length
diff --git a/test/files/neg/viewtest.check b/test/files/neg/viewtest.check
index f7920de368..b98b56bce5 100644
--- a/test/files/neg/viewtest.check
+++ b/test/files/neg/viewtest.check
@@ -2,6 +2,6 @@ viewtest.scala:104 error: ambiguous implicit value:
both method view4 in object O of type [a](a)a
and method identity in object Predef of type [a](a)a
match expected type (test.Str) => test.Ordered[test.Str]
- t = t insert Str(s)
+ t = t insert Str(s)
^
one error found
diff --git a/test/files/neg/viewtest.scala b/test/files/neg/viewtest.scala
index deb6480983..5a8abdccfd 100644
--- a/test/files/neg/viewtest.scala
+++ b/test/files/neg/viewtest.scala
@@ -1,4 +1,4 @@
-package test;
+package test
/** A trait for totally ordered data.
*/
@@ -10,15 +10,15 @@ trait Ordered[+a] {
* x == 0 iff this == that
* x > 0 iff this > that
*/
- def compareTo [b >: a <% Ordered[b]](that: b): int;
+ def compareTo [b >: a <% Ordered[b]](that: b): int
- def < [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) < 0;
+ def < [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) < 0
- def > [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) > 0;
+ def > [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) > 0
- def <= [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) <= 0;
+ def <= [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) <= 0
- def >= [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) >= 0;
+ def >= [b >: a <% Ordered[b]](that: b): boolean = (this compareTo that) >= 0
}
@@ -26,13 +26,13 @@ object O {
implicit def view1(x: String): Ordered[String] = new Ordered[String] {
def compareTo [b >: String <% Ordered[b]](y: b): int = y match {
- case y1: String => x compareTo y1;
+ case y1: String => x compareTo y1
case _ => -(y compareTo x)
}
}
implicit def view2(x: char): Ordered[char] = new Ordered[char] {
def compareTo [b >: char <% Ordered[b]](y: b): int = y match {
- case y1: char => x - y1;
+ case y1: char => x - y1
case _ => -(y compareTo x)
}
}
@@ -40,38 +40,38 @@ object O {
implicit def view3[a <% Ordered[a]](x: List[a]): Ordered[List[a]] =
new Ordered[List[a]] {
def compareTo [b >: List[a] <% Ordered[b]](y: b): int = y match {
- case y1: List[a] => compareLists(x, y1);
- case _ => -(y compareTo x)
+ case y1: List[a] => compareLists(x, y1)
+ case _ => -(y compareTo x)
}
private def compareLists(xs: List[a], ys: List[a]): int = {
- if (xs.isEmpty && ys.isEmpty) 0
- else if (xs.isEmpty) -1
- else if (ys.isEmpty) 1
- else {
- val s = xs.head compareTo ys.head;
- if (s != 0) s
- else compareLists(xs.tail, ys.tail)
- }
+ if (xs.isEmpty && ys.isEmpty) 0
+ else if (xs.isEmpty) -1
+ else if (ys.isEmpty) 1
+ else {
+ val s = xs.head compareTo ys.head
+ if (s != 0) s
+ else compareLists(xs.tail, ys.tail)
+ }
}
}
- implicit def view4[a](x: a): a = x;
+ implicit def view4[a](x: a): a = x
}
trait Tree[+a <% Ordered[a]] {
- def insert[b >: a <% Ordered[b]](x: b): Tree[b];
+ def insert[b >: a <% Ordered[b]](x: b): Tree[b]
def elements: List[a]
}
-object Empty extends Tree[All] {
- def insert[b >: All <% Ordered[b]](x: b): Tree[b] = new Node(x, Empty, Empty);
- def elements: List[All] = List();
+object Empty extends Tree[Nothing] {
+ def insert[b >: Nothing <% Ordered[b]](x: b): Tree[b] = new Node(x, Empty, Empty)
+ def elements: List[Nothing] = List()
}
class Node[a <% Ordered[a]](elem: a, l: Tree[a], r: Tree[a]) extends Tree[a] {
def insert[b >: a <% Ordered[b]](x: b): Tree[b] =
if (x == elem) this
else if (x < elem) new Node(elem, l insert x, r)
- else new Node(elem, l, r insert x);
+ else new Node(elem, l, r insert x)
def elements: List[a] =
l.elements ::: List(elem) ::: r.elements
}
@@ -84,31 +84,31 @@ case class Str(elem: String) extends Ordered[Str] {
}
object Test {
- import O._;
+ import O._
private def toCharList(s: String): List[Char] =
if (s.length() == 0) List()
- else s.charAt(0) :: toCharList(s.substring(1));
+ else s.charAt(0) :: toCharList(s.substring(1))
def main(args: Array[String]) = {
{
- var t: Tree[String] = Empty;
+ var t: Tree[String] = Empty
for (val s <- args) {
- t = t insert s
+ t = t insert s
}
System.out.println(t.elements)
}
{
- var t: Tree[Str] = Empty;
+ var t: Tree[Str] = Empty
for (val s <- args) {
- t = t insert Str(s)
+ t = t insert Str(s)
}
System.out.println(t.elements)
}
{
- var t: Tree[List[char]] = Empty;
+ var t: Tree[List[char]] = Empty
for (val s <- args) {
- t = t insert toCharList(s)
+ t = t insert toCharList(s)
}
System.out.println(t.elements)
}
diff --git a/test/files/pos/infer.scala b/test/files/pos/infer.scala
index 24871458b3..6aeed40491 100644
--- a/test/files/pos/infer.scala
+++ b/test/files/pos/infer.scala
@@ -1,11 +1,11 @@
object test {
class List[+a] {
- def ::[b >: a](x: b): List[b] = new Cons(x, this);
+ def ::[b >: a](x: b): List[b] = new Cons(x, this)
}
- case class Cons[a, b <: a](x: a, xs: List[b]) extends List[a];
- case object Nil extends List[All];
- def nil[n]: List[n] = Nil;
- def cons[a](x: a, xs: List[a]): List[a] = null;
- val x: List[Int] = Nil.::(1);
- val y: List[Int] = nil.::(1);
+ case class Cons[a, b <: a](x: a, xs: List[b]) extends List[a]
+ case object Nil extends List[Nothing]
+ def nil[n]: List[n] = Nil
+ def cons[a](x: a, xs: List[a]): List[a] = null
+ val x: List[Int] = Nil.::(1)
+ val y: List[Int] = nil.::(1)
}
diff --git a/test/files/pos/patterns.scala b/test/files/pos/patterns.scala
index 93907e7d52..85d8a1b7da 100644
--- a/test/files/pos/patterns.scala
+++ b/test/files/pos/patterns.scala
@@ -1,27 +1,29 @@
trait Option[+a] {}
+
case class Some[a](x: a) extends Option[a] {
- override def toString(): String = "Some(" + x + ")";
+ override def toString(): String = "Some(" + x + ")"
override def equals(that: Any): Boolean = that match {
case Some(x) => this.x == x
case _ => false
}
- override def hashCode(): scala.Int = getClass().hashCode() * 41 + x.hashCode();
+ override def hashCode(): Int = getClass().hashCode() * 41 + x.hashCode()
}
-case object None extends Option[All] {
- override def toString(): String = "None";
+
+case object None extends Option[Nothing] {
+ override def toString(): String = "None"
override def equals(that: Any) = that match {
case None => true
case _ => false
}
- override def hashCode(): scala.Int = getClass().hashCode();
+ override def hashCode(): Int = getClass().hashCode()
}
object test {
- def println(str: String): Unit = java.lang.System.out.println(str);
+ def println(str: String): Unit = java.lang.System.out.println(str)
def print(opt: Option[String]) = opt match {
- case Some(x) => println(x);
- case None => println("nothing");
+ case Some(x) => println(x)
+ case None => println("nothing")
}
}
diff --git a/test/files/pos/patterns1.scala b/test/files/pos/patterns1.scala
index fa542e7b06..f660ea0543 100644
--- a/test/files/pos/patterns1.scala
+++ b/test/files/pos/patterns1.scala
@@ -1,13 +1,15 @@
-trait Option[+a] {}
-case class Some[a](x: a) extends Option[a];
-case object None extends Option[All];
+trait Option[+a]
+
+case class Some[a](x: a) extends Option[a]
+
+case object None extends Option[Nothing]
object test {
- def println(str: String): Unit = java.lang.System.out.println(str);
+ def println(str: String): Unit = java.lang.System.out.println(str)
def print(opt: Option[String]) = opt match {
- case Some(x) => println(x);
- case None => println("nothing");
+ case Some(x) => println(x)
+ case None => println("nothing")
}
-} \ No newline at end of file
+}
diff --git a/test/files/pos/simplelists.scala b/test/files/pos/simplelists.scala
index 73b04a8762..ed3d5d2c38 100644
--- a/test/files/pos/simplelists.scala
+++ b/test/files/pos/simplelists.scala
@@ -1,17 +1,16 @@
- abstract class List[+a] {
- def head: a;
- def tail: List[a];
- def cons[b >: a](x: b): List[b] = new Cons[b, a](x, this);
- }
+abstract class List[+a] {
+ def head: a
+ def tail: List[a]
+ def cons[b >: a](x: b): List[b] = new Cons[b, a](x, this)
+}
- object Nil extends List[All] {
- def error(msg: String): All = throw new java.lang.Error(msg);
- def head: All = error("Nil.head");
- def tail: List[All] = error("Nil.tail");
- }
-
- class Cons[c, d <: c](x: c, xs: List[d]) extends List[c] {
- def head: c = x;
- def tail: List[c] = xs;
- }
+object Nil extends List[Nothing] {
+ def error(msg: String): Nothing = throw new java.lang.Error(msg)
+ def head: Nothing = error("Nil.head")
+ def tail: List[Nothing] = error("Nil.tail")
+}
+class Cons[c, d <: c](x: c, xs: List[d]) extends List[c] {
+ def head: c = x
+ def tail: List[c] = xs
+}
diff --git a/test/files/pos/viewtest1.scala b/test/files/pos/viewtest1.scala
index 46acefa32e..4019690961 100644
--- a/test/files/pos/viewtest1.scala
+++ b/test/files/pos/viewtest1.scala
@@ -10,7 +10,7 @@ object O {
}
}
-object Empty extends Tree[All]
+object Empty extends Tree[Nothing]
case class Node[c <% Ordered[c]](elem: c, l: Tree[c], r: Tree[c]) extends Tree[c]
trait Tree[+a <% Ordered[a]] {
diff --git a/test/files/pos/viewtest2.scala b/test/files/pos/viewtest2.scala
index 70257baa29..66cd1aa1bd 100644
--- a/test/files/pos/viewtest2.scala
+++ b/test/files/pos/viewtest2.scala
@@ -61,9 +61,9 @@ trait Tree[+a <% Ordered[a]] {
def elements: List[a]
}
-object Empty extends Tree[All] {
- def insert[b >: All <% Ordered[b]](x: b): Tree[b] = new Node(x, Empty, Empty)
- def elements: List[All] = List()
+object Empty extends Tree[Nothing] {
+ def insert[b >: Nothing <% Ordered[b]](x: b): Tree[b] = new Node(x, Empty, Empty)
+ def elements: List[Nothing] = List()
}
class Node[a <% Ordered[a]](elem: a, l: Tree[a], r: Tree[a]) extends Tree[a] {