diff --git a/sources/scalac/ast/parser/Parser.java b/sources/scalac/ast/parser/Parser.java index 2e925b39c..3f376c819 100644 --- a/sources/scalac/ast/parser/Parser.java +++ b/sources/scalac/ast/parser/Parser.java @@ -1637,26 +1637,22 @@ public class Parser implements Tokens { /** ObjectDef ::= Id [`:' SimpleType] ClassTemplate */ Tree objectDef(int mods) { - return make.ObjectDef( + return make.ModuleDef( s.pos, mods, ident(), simpleTypedOpt(), classTemplate()); } - /** ClassTemplate ::= `extends' Template - * | TemplateBody - * | + /** ClassTemplate ::= [`extends' Constr] {`with' Constr} [TemplateBody] */ Template classTemplate() { int pos = s.pos; if (s.token == EXTENDS) { s.nextToken(); return template(); -/* } else if (s.token == WITH) { s.nextToken(); TreeList parents = new TreeList(); parents.append(scalaObjectConstr(pos)); return template(parents); -*/ } else if (s.token == LBRACE) { return (Template)make.Template( pos, new Tree[]{scalaObjectConstr(pos)}, templateBody()); diff --git a/sources/scalac/ast/parser/Scanner.java b/sources/scalac/ast/parser/Scanner.java index 96f2c1dc4..07e563a9b 100644 --- a/sources/scalac/ast/parser/Scanner.java +++ b/sources/scalac/ast/parser/Scanner.java @@ -491,7 +491,6 @@ public class Scanner extends TokenData { name = Name.fromAscii(buf, start, end - start); if (name.index <= maxKey) { token = key[name.index]; - if (token == OBJECT1) token = OBJECT; //todo: elim } else token = IDENTIFIER; diff --git a/sources/scalac/typechecker/Infer.java b/sources/scalac/typechecker/Infer.java index 413785179..c818d93cb 100644 --- a/sources/scalac/typechecker/Infer.java +++ b/sources/scalac/typechecker/Infer.java @@ -981,7 +981,8 @@ public class Infer implements Modifiers, Kinds { alts[best], alttypes[best], alts[i], alttypes[i]) + " argument types " + ArrayApply.toString(argtypes, "(", ",", ")") + - " and expected result type " + pt); + ((pt == Type.AnyType) ? "" + : " and expected result type " + pt)); } } tree.setSymbol(alts[best]).setType(alttypes[best]); diff --git a/sources/scalac/typechecker/RefCheck.java b/sources/scalac/typechecker/RefCheck.java index e65c605f2..b7c89aef9 100644 --- a/sources/scalac/typechecker/RefCheck.java +++ b/sources/scalac/typechecker/RefCheck.java @@ -258,7 +258,7 @@ public class RefCheck extends Transformer implements Modifiers, Kinds { if (caseSeen.isCaseClass()) unit.error( clazz.pos, "illegal combination of case " + - caseSeen + "and case " + baseClazz + " in one object"); + caseSeen + "and case " + baseclazz + " in one object"); else caseSeen = baseclazz; @@ -804,7 +804,7 @@ public class RefCheck extends Transformer implements Modifiers, Kinds { if (sym.isLocal() && !sym.isModule() && index <= maxindex[level]) { if (Global.instance.debug) System.out.println(refsym[level] + ":" + refsym[level].type()); - String kind == ((sym.flags & MUTABLE) != 0) ? "variable" : "value"; + String kind = ((sym.flags & MUTABLE) != 0) ? "variable" : "value"; unit.error( refpos[level], "forward reference extends over definition of " + kind + " " + diff --git a/test/files/neg/stable.scala b/test/files/neg/stable.scala index 0c629c04d..664ef0b05 100644 --- a/test/files/neg/stable.scala +++ b/test/files/neg/stable.scala @@ -1,6 +1,6 @@ abstract class C { type T; val next: C = this } -module test { +object test { val x: C = new C { type T = int }; var y: C = x; diff --git a/test/files/pos/infer.scala b/test/files/pos/infer.scala index adb586b73..24871458b 100644 --- a/test/files/pos/infer.scala +++ b/test/files/pos/infer.scala @@ -1,4 +1,4 @@ -module test { +object test { class List[+a] { def ::[b >: a](x: b): List[b] = new Cons(x, this); } diff --git a/test/files/pos/infer2.scala b/test/files/pos/infer2.scala index 5e93446cd..66f3d7654 100644 --- a/test/files/pos/infer2.scala +++ b/test/files/pos/infer2.scala @@ -1,4 +1,4 @@ -module test { +object test { def f[a, b <: a](x: b): a = x: a; def g[a >: b, b](x: b): a = x: a; diff --git a/test/files/pos/patterns3.scala b/test/files/pos/patterns3.scala index 6caa83485..001bd8989 100644 --- a/test/files/pos/patterns3.scala +++ b/test/files/pos/patterns3.scala @@ -1,5 +1,5 @@ -module M { +object M { val Tuple2(Tuple2(x, y), _) = Tuple2(Tuple2(1, 2), 3); -} \ No newline at end of file +} diff --git a/test/files/run/Course-2002-05.scala b/test/files/run/Course-2002-05.scala index bc5e98592..2d8a14662 100644 --- a/test/files/run/Course-2002-05.scala +++ b/test/files/run/Course-2002-05.scala @@ -3,7 +3,7 @@ //############################################################################ // $Id$ -module M0 { +object M0 { def partition[a](xs: List[a], pred: a => boolean): Pair[List[a], List[a]] = { if (xs.isEmpty) Pair(List(),List()) @@ -49,7 +49,7 @@ module M0 { //############################################################################ -module M1 { +object M1 { def partition[a](xs: List[a], pred: a => boolean): Pair[List[a], List[a]] = { xs.foldRight[Pair[List[a], List[a]]](Pair(List(), List())) { (x, p) => if (pred (x)) Pair(x :: p._1, p._2) else Pair(p._1, x :: p._2) @@ -89,7 +89,7 @@ module M1 { //############################################################################ -module M2 { +object M2 { def powerset[a] (s : List[a]) : List[List[a]] = { if (s.isEmpty) @@ -113,7 +113,7 @@ module M2 { //############################################################################ -module M3 { +object M3 { type Placement = List[Pair[int,int]]; @@ -156,7 +156,7 @@ module M3 { //############################################################################ -module Test { +object Test { def main(args: Array[String]): unit = { M0.test; M1.test; diff --git a/test/files/run/arrays.scala b/test/files/run/arrays.scala index 605c3c2c4..8d375166d 100644 --- a/test/files/run/arrays.scala +++ b/test/files/run/arrays.scala @@ -5,7 +5,7 @@ //############################################################################ -module arrays { +object arrays { type JObject = java.lang.Object; type JSet = java.util.Set; @@ -146,7 +146,7 @@ module arrays { //############################################################################ -module Test { +object Test { def main(args: Array[String]): Unit = { arrays.test; diff --git a/test/neg/stable.scala b/test/neg/stable.scala index 0c629c04d..664ef0b05 100644 --- a/test/neg/stable.scala +++ b/test/neg/stable.scala @@ -1,6 +1,6 @@ abstract class C { type T; val next: C = this } -module test { +object test { val x: C = new C { type T = int }; var y: C = x; diff --git a/test/pos/infer.scala b/test/pos/infer.scala index adb586b73..24871458b 100644 --- a/test/pos/infer.scala +++ b/test/pos/infer.scala @@ -1,4 +1,4 @@ -module test { +object test { class List[+a] { def ::[b >: a](x: b): List[b] = new Cons(x, this); } diff --git a/test/pos/infer2.scala b/test/pos/infer2.scala index 5e93446cd..66f3d7654 100644 --- a/test/pos/infer2.scala +++ b/test/pos/infer2.scala @@ -1,4 +1,4 @@ -module test { +object test { def f[a, b <: a](x: b): a = x: a; def g[a >: b, b](x: b): a = x: a; diff --git a/test/pos/patterns3.scala b/test/pos/patterns3.scala index 6caa83485..001bd8989 100644 --- a/test/pos/patterns3.scala +++ b/test/pos/patterns3.scala @@ -1,5 +1,5 @@ -module M { +object M { val Tuple2(Tuple2(x, y), _) = Tuple2(Tuple2(1, 2), 3); -} \ No newline at end of file +}