From efd06d74f1621351c70456478b07a4ace6a9a211 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 31 Mar 2003 08:29:52 +0000 Subject: *** empty log message *** --- test/files/neg/S2.scala | 2 +- test/files/neg/altherr1.scala | 2 +- test/files/neg/altherr2.scala | 2 +- test/files/neg/altherr3.scala | 2 +- test/files/neg/vincent1.scala | 2 +- test/files/pos/A.scala | 2 +- test/files/pos/IntSet.scala | 6 +++--- test/files/pos/List1.scala | 2 +- test/files/pos/S5.scala | 2 +- test/files/pos/S8.scala | 2 +- test/files/pos/Y.scala | 2 +- test/files/pos/Z.scala | 2 +- test/files/pos/cls.scala | 2 +- test/files/pos/clsrefine.scala | 2 +- test/files/pos/cours1.scala | 2 +- test/files/pos/cours2.scala | 18 +++++++++--------- test/files/pos/cours2a.scala | 4 ++-- test/files/pos/cours2b.scala | 2 +- test/files/pos/cours2c.scala | 4 ++-- test/files/pos/eta.scala | 2 +- test/files/pos/exceptions.scala | 2 +- test/files/pos/imports.scala | 4 ++-- test/files/pos/lambda.scala | 2 +- test/files/pos/lambdalift.scala | 2 +- test/files/pos/lambdalift1.scala | 2 +- test/files/pos/localmodules.scala | 22 +++++++++++++++++++++ test/files/pos/matthias1.scala | 2 +- test/files/pos/matthias4.scala | 26 ++++++++++++------------- test/files/pos/maxim1.scala | 2 +- test/files/pos/modules.scala | 4 ++-- test/files/pos/modules1.scala | 6 +++--- test/files/pos/moduletrans.scala | 2 +- test/files/pos/null.scala | 2 +- test/files/pos/partialfun.scala | 2 +- test/files/pos/patterns.scala | 2 +- test/files/pos/patterns2.scala | 2 +- test/files/pos/philippe1.scala | 2 +- test/files/pos/philippe3.scala | 12 ++++++------ test/files/pos/reftest.scala | 2 +- test/files/pos/sort1.scala | 2 +- test/files/pos/sqrt.scala | 2 +- test/files/pos/strings.scala | 2 +- test/files/pos/test1.scala | 2 +- test/files/pos/test2.scala | 2 +- test/files/pos/test4.scala | 4 ++-- test/files/pos/test4a.scala | 2 +- test/files/pos/test4refine.scala | 4 ++-- test/files/pos/test5.scala | 2 +- test/files/pos/test5refine.scala | 2 +- test/files/pos/valdefs.scala | 2 +- test/files/pos/vincent.scala | 21 ++++++++++++++++++++ test/files/run/Course-2002-01.scala | 12 ++++++------ test/files/run/Course-2002-02.scala | 38 ++++++++++++++++++------------------- test/files/run/Course-2002-03.scala | 28 +++++++++++++-------------- test/files/run/Course-2002-04.scala | 8 ++++---- test/files/run/Course-2002-06.scala | 4 ++-- test/files/run/Course-2002-07.scala | 28 +++++++++++++-------------- test/files/run/Course-2002-08.scala | 14 +++++++------- test/files/run/Course-2002-09.scala | 12 ++++++------ test/files/run/Course-2002-10.scala | 8 ++++---- test/files/run/Course-2002-11.scala | 8 ++++---- test/files/run/Course-2002-13.scala | 8 ++++---- test/files/run/misc.scala | 2 +- test/files/run/queens.scala | 4 ++-- test/neg/S2.scala | 2 +- test/neg/altherr1.scala | 2 +- test/neg/altherr2.scala | 2 +- test/neg/altherr3.scala | 2 +- test/neg/vincent1.scala | 2 +- test/pos/A.scala | 2 +- test/pos/IntSet.scala | 6 +++--- test/pos/List1.scala | 2 +- test/pos/S5.scala | 2 +- test/pos/S8.scala | 2 +- test/pos/Y.scala | 2 +- test/pos/Z.scala | 2 +- test/pos/cls.scala | 2 +- test/pos/clsrefine.scala | 2 +- test/pos/cours1.scala | 2 +- test/pos/cours2.scala | 18 +++++++++--------- test/pos/cours2a.scala | 4 ++-- test/pos/cours2b.scala | 2 +- test/pos/cours2c.scala | 4 ++-- test/pos/eta.scala | 2 +- test/pos/exceptions.scala | 2 +- test/pos/imports.scala | 4 ++-- test/pos/lambda.scala | 2 +- test/pos/lambdalift.scala | 2 +- test/pos/lambdalift1.scala | 2 +- test/pos/localmodules.scala | 22 +++++++++++++++++++++ test/pos/matthias1.scala | 2 +- test/pos/matthias4.scala | 26 ++++++++++++------------- test/pos/maxim1.scala | 2 +- test/pos/modules.scala | 4 ++-- test/pos/modules1.scala | 6 +++--- test/pos/moduletrans.scala | 2 +- test/pos/null.scala | 2 +- test/pos/partialfun.scala | 2 +- test/pos/patterns.scala | 2 +- test/pos/patterns2.scala | 2 +- test/pos/philippe1.scala | 2 +- test/pos/philippe3.scala | 12 ++++++------ test/pos/reftest.scala | 2 +- test/pos/sort1.scala | 2 +- test/pos/sqrt.scala | 2 +- test/pos/strings.scala | 2 +- test/pos/test1.scala | 2 +- test/pos/test2.scala | 2 +- test/pos/test4.scala | 4 ++-- test/pos/test4a.scala | 2 +- test/pos/test4refine.scala | 4 ++-- test/pos/test5.scala | 2 +- test/pos/test5refine.scala | 2 +- test/pos/valdefs.scala | 2 +- test/pos/vincent.scala | 21 ++++++++++++++++++++ 115 files changed, 341 insertions(+), 255 deletions(-) create mode 100644 test/files/pos/localmodules.scala create mode 100644 test/files/pos/vincent.scala create mode 100644 test/pos/localmodules.scala create mode 100644 test/pos/vincent.scala (limited to 'test') diff --git a/test/files/neg/S2.scala b/test/files/neg/S2.scala index 83cc1829a3..47687a916a 100644 --- a/test/files/neg/S2.scala +++ b/test/files/neg/S2.scala @@ -7,7 +7,7 @@ ** def t = foo(x, y); ** ^ */ -module M { +object M { def foo[T](x: T, y: T): T = x; class S2() { class Inner() extends S2() {} diff --git a/test/files/neg/altherr1.scala b/test/files/neg/altherr1.scala index 69443bfd06..9eb0cc9987 100644 --- a/test/files/neg/altherr1.scala +++ b/test/files/neg/altherr1.scala @@ -1,6 +1,6 @@ case class Foo[a](); -module Bug { +object Bug { def foo[a](): Foo[a] = foo[a](); foo() match { case _ => 0 } } diff --git a/test/files/neg/altherr2.scala b/test/files/neg/altherr2.scala index 41bcffca36..6ab26526f7 100644 --- a/test/files/neg/altherr2.scala +++ b/test/files/neg/altherr2.scala @@ -1,6 +1,6 @@ trait Foo[a]; -module Bug { +object Bug { def foo[a](): Foo[a] = foo[a](); foo()[Int]; } diff --git a/test/files/neg/altherr3.scala b/test/files/neg/altherr3.scala index bb40099e1e..a96513e832 100644 --- a/test/files/neg/altherr3.scala +++ b/test/files/neg/altherr3.scala @@ -1,6 +1,6 @@ // $Id$ -module bug { +object bug { //########################################################################## diff --git a/test/files/neg/vincent1.scala b/test/files/neg/vincent1.scala index 53104be640..6082b271b3 100644 --- a/test/files/neg/vincent1.scala +++ b/test/files/neg/vincent1.scala @@ -1,4 +1,4 @@ -module test { +object test { trait A { type T; } diff --git a/test/files/pos/A.scala b/test/files/pos/A.scala index 2f7c958ae2..513c8bed45 100644 --- a/test/files/pos/A.scala +++ b/test/files/pos/A.scala @@ -1,6 +1,6 @@ trait A extends scala.Object {} -module test { +object test { def x: A = x; diff --git a/test/files/pos/IntSet.scala b/test/files/pos/IntSet.scala index cfffc88944..639a099d9a 100644 --- a/test/files/pos/IntSet.scala +++ b/test/files/pos/IntSet.scala @@ -4,8 +4,8 @@ trait IntSet { def foreach(f: Int => Unit): Unit; def union(that: IntSet): IntSet; } -module Empty extends IntSet { - def contains(x: Int): Boolean = false; +object Empty extends IntSet { + def contains(x: Int): Boolean = Boolean.False; def incl(x: Int): IntSet = new NonEmpty(x, Empty, Empty); def foreach(f: Int => Unit): Unit = (); def union(that: IntSet): IntSet = that; @@ -26,7 +26,7 @@ class NonEmpty(elem: Int, left: IntSet, right: IntSet) extends IntSet { } def union(that: IntSet): IntSet = (left union (right union that)) incl elem; } -module test { +object test { def main = { val x = Empty incl 1 incl 2; val y = Empty incl 2 incl 3; diff --git a/test/files/pos/List1.scala b/test/files/pos/List1.scala index fcc506bccc..6c54f109ce 100644 --- a/test/files/pos/List1.scala +++ b/test/files/pos/List1.scala @@ -1,4 +1,4 @@ -module lists { +object lists { trait List[a] { def isEmpty: Boolean; diff --git a/test/files/pos/S5.scala b/test/files/pos/S5.scala index 87325b47e4..08f5b2a6eb 100644 --- a/test/files/pos/S5.scala +++ b/test/files/pos/S5.scala @@ -25,6 +25,6 @@ abstract class N() { // module body of N } } -module O { +object O { val system = new M() with N() {} } diff --git a/test/files/pos/S8.scala b/test/files/pos/S8.scala index e4339bb3f1..50f1df27a2 100644 --- a/test/files/pos/S8.scala +++ b/test/files/pos/S8.scala @@ -13,7 +13,7 @@ class S8() { class A() extends a.B() {} class B() {} } -module M { +object M { val x = new S8(); val y: x.a.B = new x.A(); //correct? } diff --git a/test/files/pos/Y.scala b/test/files/pos/Y.scala index 425d7fb346..ebef6f9e36 100644 --- a/test/files/pos/Y.scala +++ b/test/files/pos/Y.scala @@ -1,4 +1,4 @@ -module test { +object test { def f(x: Object): Object = x.match; diff --git a/test/files/pos/Z.scala b/test/files/pos/Z.scala index c19081e68c..c1367e46b9 100644 --- a/test/files/pos/Z.scala +++ b/test/files/pos/Z.scala @@ -2,7 +2,7 @@ trait X { val elem: Int = 1 } -module test { +object test { def g(x: X) = x.elem; def f(x: Object) = x.toString(); diff --git a/test/files/pos/cls.scala b/test/files/pos/cls.scala index 3a46c306db..54104ae692 100644 --- a/test/files/pos/cls.scala +++ b/test/files/pos/cls.scala @@ -8,7 +8,7 @@ class B[Y](y1: Y, y2: Y) extends A[Y, Y](y1, y2) { def g() = f(y1, this); } -module test { +object test { val b: B[Int] = new B[Int](1, 2); val a: A[Int, Int] = b; val a1 = new A(1, "hello"); diff --git a/test/files/pos/clsrefine.scala b/test/files/pos/clsrefine.scala index 12f5aa5246..56db9d4c13 100644 --- a/test/files/pos/clsrefine.scala +++ b/test/files/pos/clsrefine.scala @@ -15,7 +15,7 @@ trait B extends A { def g() = f(y1, this); } -module test { +object test { val b: B { type Y = Int } = new B { type Y = Int; val y1 = 1, y2 = 1; diff --git a/test/files/pos/cours1.scala b/test/files/pos/cours1.scala index 48b5f6504d..2dc3ac6238 100644 --- a/test/files/pos/cours1.scala +++ b/test/files/pos/cours1.scala @@ -1,4 +1,4 @@ -module test { +object test { def size = 2; def pi = 3.14159; diff --git a/test/files/pos/cours2.scala b/test/files/pos/cours2.scala index 032531b25e..c96f588791 100644 --- a/test/files/pos/cours2.scala +++ b/test/files/pos/cours2.scala @@ -1,4 +1,4 @@ -module m1 { +object m1 { def id(x: Int): Double = x; def cube(x: Int): Double = x * x * x; @@ -18,7 +18,7 @@ module m1 { } -module m2 { +object m2 { def id(x: Int): Double = x; def cube(x: Int): Double = x * x * x; @@ -33,7 +33,7 @@ module m2 { def sumReciprocals(a: Int, b: Int): Double = sum(reciprocal, a, b); } -module m3 { +object m3 { def sum(f: Int => Double, a: Int, b: Int): Double = if (a > b) 0 @@ -44,7 +44,7 @@ module m3 { def sumReciprocals(a: Int, b: Int): Double = sum((x => 1.0/x), a, b); } -module m4 { +object m4 { def sum(f: Int => Double) = { def sumF(a: Int, b: Int): Double = @@ -60,7 +60,7 @@ module m4 { sumCubes(1, 10) + sumReciprocals(10, 20); } -module m5 { +object m5 { def sum(f: Int => Double): (Int, Int) => Double = (a, b) => if (a > b) 0 @@ -73,7 +73,7 @@ module m5 { sumCubes(1, 10) + sumReciprocals(10, 20); } -module m6 { +object m6 { def sum(f: Int => Double)(a: Int, b: Int): Double = if (a > b) 0 @@ -86,7 +86,7 @@ module m6 { sumCubes(1, 10) + sumReciprocals(10, 20); } -module m7 { +object m7 { def sum(f: Int => Double)(a: Int, b: Int): Double = { def iter(a: Int, result: Double): Double = @@ -102,7 +102,7 @@ module m7 { sumCubes(1, 10) + sumReciprocals(10, 20); } -module m8 { +object m8 { def product(f: Int => Double)(a: Int, step: Int, b: Int): Double = if (a > b) 1 @@ -111,7 +111,7 @@ module m8 { val pi = 8 * product(x => x * x)(4, 2, 40) / product(x => x * x)(3, 2, 40); } -module m9 { +object m9 { def accumulate[t](combiner: (t, t) => t, nullValue: t, f: Int => t, next: Int => Int) (a: Int, b: Int): t = diff --git a/test/files/pos/cours2a.scala b/test/files/pos/cours2a.scala index b888b88a96..9afa703cd7 100644 --- a/test/files/pos/cours2a.scala +++ b/test/files/pos/cours2a.scala @@ -1,10 +1,10 @@ -module m1 { +object m1 { def factorial(n: Int): Int = if (n == 0) 1 else n * factorial(n-1); } -module m2 { +object m2 { def factorial(n: Int): Int = { def factIter(n: Int, acc: Int): Int = { diff --git a/test/files/pos/cours2b.scala b/test/files/pos/cours2b.scala index edac3ed483..aea7029656 100644 --- a/test/files/pos/cours2b.scala +++ b/test/files/pos/cours2b.scala @@ -1,4 +1,4 @@ -module m1 { +object m1 { def gcd(x: Int, y: Int): Int = if (y == 0) x diff --git a/test/files/pos/cours2c.scala b/test/files/pos/cours2c.scala index c2e4b221d5..776469e1bb 100644 --- a/test/files/pos/cours2c.scala +++ b/test/files/pos/cours2c.scala @@ -1,4 +1,4 @@ -module m1 { +object m1 { def average(x: Double, y: Double) = (x + y)/2; def abs(x: Double): Double = if (x < 0) - x else x; @@ -25,7 +25,7 @@ module m1 { } } -module m2 { +object m2 { def abs(x: Double): Double = if (x < 0) - x else x; def isCloseEnough(x: Double, y: Double) = abs((x - y) / x) < 0.001; diff --git a/test/files/pos/eta.scala b/test/files/pos/eta.scala index 67e6c0f080..7d862f67b1 100644 --- a/test/files/pos/eta.scala +++ b/test/files/pos/eta.scala @@ -1,4 +1,4 @@ -module test { +object test { def sum(f: Int => Int)(x: Int, y: Int): Int = 0; def g = sum; diff --git a/test/files/pos/exceptions.scala b/test/files/pos/exceptions.scala index 4c7ffa35c8..7c376f3aac 100644 --- a/test/files/pos/exceptions.scala +++ b/test/files/pos/exceptions.scala @@ -1,6 +1,6 @@ import java.io._; -module test { +object test { //def error[a](x: String):a = new java.lang.RuntimeException(x) throw; diff --git a/test/files/pos/imports.scala b/test/files/pos/imports.scala index f13a3a4368..32b7aace62 100644 --- a/test/files/pos/imports.scala +++ b/test/files/pos/imports.scala @@ -4,7 +4,7 @@ package test; import java.lang.{System => S} -module test { +object test { import S.out.{print => p, println => print} val foo = 1; @@ -12,7 +12,7 @@ module test { p("hello"); print("world"); S.out.println("!"); S.out.flush(); } -module test1 { +object test1 { import test._; foo } \ No newline at end of file diff --git a/test/files/pos/lambda.scala b/test/files/pos/lambda.scala index 27c273cc3c..187b3f9783 100644 --- a/test/files/pos/lambda.scala +++ b/test/files/pos/lambda.scala @@ -1,4 +1,4 @@ -module test { +object test { def apply[a,b](f: a => b): a => b = x: a => f(x); diff --git a/test/files/pos/lambdalift.scala b/test/files/pos/lambdalift.scala index f780b8e13f..ae5799a6f8 100644 --- a/test/files/pos/lambdalift.scala +++ b/test/files/pos/lambdalift.scala @@ -1,6 +1,6 @@ import scala._; -module test { +object test { def f(x: Int) = { def g() = h(); diff --git a/test/files/pos/lambdalift1.scala b/test/files/pos/lambdalift1.scala index e4c7b3a801..d9172f51eb 100644 --- a/test/files/pos/lambdalift1.scala +++ b/test/files/pos/lambdalift1.scala @@ -1,6 +1,6 @@ import scala._; -module test { +object test { def f[a <: java.lang.Object](x: a) = { def print() = java.lang.System.out.println(x); diff --git a/test/files/pos/localmodules.scala b/test/files/pos/localmodules.scala new file mode 100644 index 0000000000..8ed34f455a --- /dev/null +++ b/test/files/pos/localmodules.scala @@ -0,0 +1,22 @@ +package test; + +object main { + + class a { + + object b { + + trait c {} + def foo(x: c): c = { System.out.println("foo(" + x + ")"); x } + + } + + def bar(x: b.c): a.this.b.c = { b.foo(x); x } + } + + def main(args: Array[String]) = { + val aa = new a; + val xx: aa.b.c = null; + System.out.println(aa.bar(xx)); + } +} diff --git a/test/files/pos/matthias1.scala b/test/files/pos/matthias1.scala index 418c2f32be..a923a529fe 100644 --- a/test/files/pos/matthias1.scala +++ b/test/files/pos/matthias1.scala @@ -3,7 +3,7 @@ class A() { def foo(x: B) = 0 } } -module test { +object test { def main = { val a = new A(); val b = new a.B(); diff --git a/test/files/pos/matthias4.scala b/test/files/pos/matthias4.scala index 751c8b1c88..32200cccd1 100644 --- a/test/files/pos/matthias4.scala +++ b/test/files/pos/matthias4.scala @@ -1,19 +1,19 @@ /* -module A requires B { +object A requires B { B.X getX() { return B.getX(); } void setX(B.X x) {} } -module B { +object B { class X {} X getX() { return new X(); } void setX(X x) {} } -module C requires B { - module A; +object C requires B { + object A; void test() { A.setX(B.getX()); } @@ -23,8 +23,8 @@ module C requires B { trait _a extends Object with _b { val a: _a; val A: A; - type A <: a.AModule; - trait AModule { + type A <: a.AObject; + trait AObject { def getX(): B.X; def setX(x: B.X): Unit; } @@ -32,7 +32,7 @@ trait _a extends Object with _b { abstract class a() extends Object with _a with _b { val a: this.type = this; val A: A = new A(); - class A() extends AModule { + class A() extends AObject { def getX(): B.X = B.getX(); def setX(x: B.X) = B.setX(x); } @@ -41,8 +41,8 @@ abstract class a() extends Object with _a with _b { trait _b { val b: _b; val B: B; - type B <: b.BModule; - trait BModule { + type B <: b.BObject; + trait BObject { type X; def getX(): X; def setX(x: X): Unit; @@ -51,7 +51,7 @@ trait _b { abstract class b() extends Object with _b { val b: this.type = this; val B: B = new B(); - class B() extends BModule { + class B() extends BObject { class X() {} def getX(): X = new X(); def setX(x: X) = (); @@ -61,13 +61,13 @@ abstract class b() extends Object with _b { trait _m { val m: _m; val M: M; - type M <: m.MModule; - trait MModule {} + type M <: m.MObject; + trait MObject {} } abstract class m() extends Object with _m with _b { val m: this.type = this; val M: M = new M(); - class M() extends MModule with a() with Linker() { + class M() extends MObject with a() with Linker() { def test() = { val x: B.X = B.getX(); A.setX(x); diff --git a/test/files/pos/maxim1.scala b/test/files/pos/maxim1.scala index 01a7c05e9a..58916beb8a 100644 --- a/test/files/pos/maxim1.scala +++ b/test/files/pos/maxim1.scala @@ -1,4 +1,4 @@ -module test { +object test { def f(x: Int)(y: Int) = x + y; def y: Int => Int = f(2); def main = y(1); diff --git a/test/files/pos/modules.scala b/test/files/pos/modules.scala index d916d7fd60..8168a42d3c 100644 --- a/test/files/pos/modules.scala +++ b/test/files/pos/modules.scala @@ -1,8 +1,8 @@ package scala { - module a { + object a { - module b { + object b { trait c {} def foo(x: c): c = bar(x) diff --git a/test/files/pos/modules1.scala b/test/files/pos/modules1.scala index 71c4bf8bd4..3da14af4fe 100644 --- a/test/files/pos/modules1.scala +++ b/test/files/pos/modules1.scala @@ -1,14 +1,14 @@ package scala { - module a { + object a { - module b { + object b { trait c {} def foo(x: c): c = bar(x) } - def bar(x: b.c): a.b.c = x + def bar(x: b.c): a.b.c = { b.foo(x); x } } } diff --git a/test/files/pos/moduletrans.scala b/test/files/pos/moduletrans.scala index 953ce4ee6c..51538417ed 100644 --- a/test/files/pos/moduletrans.scala +++ b/test/files/pos/moduletrans.scala @@ -1,4 +1,4 @@ -module m1 { +object m1 { class m() { def f() = 5 diff --git a/test/files/pos/null.scala b/test/files/pos/null.scala index 54a2c0f995..59f88ee0e0 100644 --- a/test/files/pos/null.scala +++ b/test/files/pos/null.scala @@ -1,3 +1,3 @@ -module M { +object M { val x: Boolean = null == null; } \ No newline at end of file diff --git a/test/files/pos/partialfun.scala b/test/files/pos/partialfun.scala index 1f27d099e4..e6af633811 100644 --- a/test/files/pos/partialfun.scala +++ b/test/files/pos/partialfun.scala @@ -1,4 +1,4 @@ -module partialfun { +object partialfun { def applyPartial[b](f: PartialFunction[Option[String], b])(x: Option[String]) = if (f.isDefinedAt(x)) f(x) else ""; diff --git a/test/files/pos/patterns.scala b/test/files/pos/patterns.scala index 18ffec5025..48c068c618 100644 --- a/test/files/pos/patterns.scala +++ b/test/files/pos/patterns.scala @@ -2,7 +2,7 @@ trait Option[a] {} case class Some[a](x: a) extends Option[a]; case class None[a] extends Option[a]; -module test { +object test { def println(str: String): Unit = java.lang.System.out.println(str); diff --git a/test/files/pos/patterns2.scala b/test/files/pos/patterns2.scala index 023aaf44af..dab73a98fc 100644 --- a/test/files/pos/patterns2.scala +++ b/test/files/pos/patterns2.scala @@ -3,7 +3,7 @@ case class Choice(a: Option, b: Option) extends Option; case class Some(x: java.lang.String) extends Option; case class None extends Option; -module test { +object test { def f(opt: Option) = opt match { case Choice(Some("one"), Some(x)) => 1; diff --git a/test/files/pos/philippe1.scala b/test/files/pos/philippe1.scala index d079c5974a..3cace0e116 100644 --- a/test/files/pos/philippe1.scala +++ b/test/files/pos/philippe1.scala @@ -1,4 +1,4 @@ -module test { +object test { def id[a](xs: Array[a]): Array[a] = xs; def main(args: Array[String]): Unit = { diff --git a/test/files/pos/philippe3.scala b/test/files/pos/philippe3.scala index d99ec41f52..9442583997 100644 --- a/test/files/pos/philippe3.scala +++ b/test/files/pos/philippe3.scala @@ -29,12 +29,12 @@ case class D6() extends C() {} case class D7() extends C() with U; case class D8() extends C() with U {} -module M1; -module M2 {} -module M5 extends C(); -module M6 extends C() {} -module M7 extends C() with U; -module M8 extends C() with U {} +object M1; +object M2 {} +object M5 extends C(); +object M6 extends C() {} +object M7 extends C() with U; +object M8 extends C() with U {} diff --git a/test/files/pos/reftest.scala b/test/files/pos/reftest.scala index 27083bd2cc..f709f70897 100644 --- a/test/files/pos/reftest.scala +++ b/test/files/pos/reftest.scala @@ -1,4 +1,4 @@ import scala._; -module test { +object test { val x: Ref[Int] = new Ref(1); } \ No newline at end of file diff --git a/test/files/pos/sort1.scala b/test/files/pos/sort1.scala index 0a75a87272..c2895fe535 100644 --- a/test/files/pos/sort1.scala +++ b/test/files/pos/sort1.scala @@ -1,4 +1,4 @@ -module test { +object test { type String = java.lang.String; diff --git a/test/files/pos/sqrt.scala b/test/files/pos/sqrt.scala index f6a53824b4..5ad1718619 100644 --- a/test/files/pos/sqrt.scala +++ b/test/files/pos/sqrt.scala @@ -1,4 +1,4 @@ -module test { +object test { def abs(x: Double) = if (x >= 0) x else 0 - x; diff --git a/test/files/pos/strings.scala b/test/files/pos/strings.scala index 75bf23f5e3..3bf40e3dda 100644 --- a/test/files/pos/strings.scala +++ b/test/files/pos/strings.scala @@ -1,5 +1,5 @@ // martin 1-3-2002: it seems there is a problem with the way Serializable is loaded. -module test { +object test { def f() = "hello".concat("world"); diff --git a/test/files/pos/test1.scala b/test/files/pos/test1.scala index 6e8e4f98a7..a36d2436ec 100644 --- a/test/files/pos/test1.scala +++ b/test/files/pos/test1.scala @@ -1,4 +1,4 @@ -module test { +object test { def f() = 5; diff --git a/test/files/pos/test2.scala b/test/files/pos/test2.scala index 4c73e0a10b..fe36d07f1b 100644 --- a/test/files/pos/test2.scala +++ b/test/files/pos/test2.scala @@ -1,5 +1,5 @@ import scala._; -module test2 { +object test2 { def f(x: Int): Int = 'a'; def g(x: Int) = f(f(x)); } \ No newline at end of file diff --git a/test/files/pos/test4.scala b/test/files/pos/test4.scala index 0bbb6f97a0..48949b7a7f 100644 --- a/test/files/pos/test4.scala +++ b/test/files/pos/test4.scala @@ -2,7 +2,7 @@ trait C {} trait D {} trait E {} -module test { +object test { def c: C = c; def d: D = d; def e: E = e; @@ -22,7 +22,7 @@ class O[X]() { val j:I[X] = null; } -module o extends O[C]() { +object o extends O[C]() { def main = { val s: S = null; diff --git a/test/files/pos/test4a.scala b/test/files/pos/test4a.scala index 0d653c5012..ada0ba4e5f 100644 --- a/test/files/pos/test4a.scala +++ b/test/files/pos/test4a.scala @@ -7,7 +7,7 @@ class O[X]() { val j:I[X] = null; } -module o extends O[C]() { +object o extends O[C]() { def c: C = c; def main = { o.j.foo(c); diff --git a/test/files/pos/test4refine.scala b/test/files/pos/test4refine.scala index ad68bc891a..6710962934 100644 --- a/test/files/pos/test4refine.scala +++ b/test/files/pos/test4refine.scala @@ -2,7 +2,7 @@ trait C {} trait D {} trait E {} -module test { +object test { def c: C = c; def d: D = d; def e: E = e; @@ -25,7 +25,7 @@ abstract class O() { val j:I { type Y = X } = null; } -module o extends O() { +object o extends O() { type X = C; def main = { diff --git a/test/files/pos/test5.scala b/test/files/pos/test5.scala index 08f91650da..bc3a17c9be 100644 --- a/test/files/pos/test5.scala +++ b/test/files/pos/test5.scala @@ -1,6 +1,6 @@ import scala._; -module test { +object test { trait F[If] {} diff --git a/test/files/pos/test5refine.scala b/test/files/pos/test5refine.scala index 7efbf5a3f1..95670faa05 100644 --- a/test/files/pos/test5refine.scala +++ b/test/files/pos/test5refine.scala @@ -1,6 +1,6 @@ import scala._; -module test { +object test { abstract trait F { type If; } diff --git a/test/files/pos/valdefs.scala b/test/files/pos/valdefs.scala index b05edbf7b2..f9150ea509 100644 --- a/test/files/pos/valdefs.scala +++ b/test/files/pos/valdefs.scala @@ -1,4 +1,4 @@ -module test { +object test { abstract class Base() { val x: String; diff --git a/test/files/pos/vincent.scala b/test/files/pos/vincent.scala new file mode 100644 index 0000000000..eed25eb84c --- /dev/null +++ b/test/files/pos/vincent.scala @@ -0,0 +1,21 @@ +object test { + + trait A { type T; } + + trait B { type T; } + + /** def functor(x: A): B { type T = x.T } */ + abstract class functor() { + val arg: A; + val res: B { type T = arg.T } = + new B { type T = arg.T; }; + } + + val a = new A { type T = String }; + /** val b: B { type T = String } = functor(a) */ + val b: B { type T = String } = { + val tmp = new functor() { val arg = a }; + tmp.res + } + +} diff --git a/test/files/run/Course-2002-01.scala b/test/files/run/Course-2002-01.scala index 33b8e2246c..11d29540af 100644 --- a/test/files/run/Course-2002-01.scala +++ b/test/files/run/Course-2002-01.scala @@ -3,7 +3,7 @@ //############################################################################ // $Id$ -module M0 { +object M0 { //########################################################################## @@ -118,7 +118,7 @@ module M0 { //############################################################################ -module M1 { +object M1 { def abs(x: Double) = if (x >= 0) x else -x; def sqrt(x: Double): Double = { @@ -139,7 +139,7 @@ module M1 { //############################################################################ -module M2 { +object M2 { def abs(x: Double) = if (x >= 0) x else -x; def sqrt(x:Double):Double = { @@ -161,7 +161,7 @@ module M2 { //############################################################################ -module M3 { +object M3 { def abs(x: Double) = if (x >= 0) x else -x; def cbrt(x:Double):Double = { @@ -183,7 +183,7 @@ module M3 { //############################################################################ -module M4 { +object M4 { def pascal(c: Int, l: Int): Int = if (c <= 0 || c >= l) 1 else pascal(c - 1, l - 1) + pascal(c, l - 1); @@ -226,7 +226,7 @@ module M4 { //############################################################################ -module Test { +object Test { def main(args: Array[String]): Unit = { M0; M1; diff --git a/test/files/run/Course-2002-02.scala b/test/files/run/Course-2002-02.scala index a39921b45b..6c78249586 100644 --- a/test/files/run/Course-2002-02.scala +++ b/test/files/run/Course-2002-02.scala @@ -3,7 +3,7 @@ //############################################################################ // $Id$ -module M0 { +object M0 { def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b); def factorial(n: Int): Int = if (n == 0) 1 else n * factorial(n - 1); @@ -14,7 +14,7 @@ module M0 { //############################################################################ -module M1 { +object M1 { def cube(x: Int): Double = x * x * x; def sumInts(a: Int, b: Int): Double = @@ -47,7 +47,7 @@ module M1 { //############################################################################ -module M2 { +object M2 { def id(x: Int): Double = x; def cube(x: Int): Double = x * x * x; def reciprocal(x: Int): Double = 1.0/x; @@ -74,7 +74,7 @@ module M2 { //############################################################################ -module M3 { +object M3 { def sum(f: Int => Double, a: Int, b: Int): Double = if (a > b) 0 else f(a) + sum(f, a + 1, b); @@ -94,7 +94,7 @@ module M3 { //############################################################################ -module M4 { +object M4 { def sum(f: Int => Double) = { def sumF(a: Int, b: Int): Double = if (a > b) 0 @@ -117,7 +117,7 @@ module M4 { //############################################################################ -module M5 { +object M5 { def sum(f: Int => Double): (Int, Int) => Double = { (a, b) => if (a > b) 0 else f(a) + sum(f)(a + 1, b) @@ -138,7 +138,7 @@ module M5 { //############################################################################ -module M6 { +object M6 { def sum(f: Int => Double)(a: Int, b: Int): Double = if (a > b) 0 else f(a) + sum(f)(a + 1, b); @@ -158,7 +158,7 @@ module M6 { //############################################################################ -module M7 { +object M7 { def sum(f: Int => Double)(a: Int, b: Int): Double = { def iter(a: Int, result: Double): Double = if (a > b) result @@ -181,7 +181,7 @@ module M7 { //############################################################################ -module M8 { +object M8 { def product(f: Int => Double)(a: Int, step: Int, b: Int): Double = if (a > b) 1 else f(a) * product(f)(a + step, step, b); @@ -197,7 +197,7 @@ module M8 { //############################################################################ -module M9 { +object M9 { def accumulate[t](combiner: (t, t) => t, nullValue: t, f: Int => t, next: Int => Int) (a: Int, b: Int): t = if (a > b) nullValue @@ -231,7 +231,7 @@ module M9 { //############################################################################ -module MA { +object MA { val tolerance = 0.0001; def abs(x: Double) = if (x < 0) -x else x; def isCloseEnough(x: Double, y: Double) = abs((x - y) / x) < tolerance; @@ -252,7 +252,7 @@ module MA { //############################################################################ -module MB { +object MB { val tolerance = 0.0001; def abs(x: Double) = if (x < 0) -x else x; def isCloseEnough(x: Double, y: Double) = abs((x - y) / x) < tolerance; @@ -274,7 +274,7 @@ module MB { //############################################################################ -module MC { +object MC { def sum(f: Int => Double)(a: Int, b: Int): Double = { def iter(a: Int, result: Double): Double = { if (a > b) result @@ -322,7 +322,7 @@ module MC { //############################################################################ -module MD { +object MD { def reduce(op: (Double,Double) => Double, zero:Double) (f: Int => Double)(a: Int,b: Int): Double = { def iter(a: Int, result: Double): Double = { @@ -366,7 +366,7 @@ module MD { //############################################################################ -module ME { +object ME { def reduce(op: (Double,Double) => Double, zero:Double) (f: Int => Double)(a: Int,b: Int): Double = { def iter(a: Int, result: Double): Double = { @@ -410,7 +410,7 @@ module ME { //############################################################################ -module MF { +object MF { def fib(x: Int): Int = if (x <= 1) x else fib(x - 2) + fib(x - 1); @@ -429,7 +429,7 @@ module MF { //############################################################################ -module MG { +object MG { def fib(x: Int) = { def loop(n: Int, prev: Int, fibn: Int): Int = if (n == x) fibn @@ -451,7 +451,7 @@ module MG { //############################################################################ -module MH { +object MH { def power(x: Double, y: Int): Double = if (y <= 0) 1 else if (y % 2 == 0) power(x * x, y / 2) @@ -527,7 +527,7 @@ module MH { //############################################################################ -module Test { +object Test { def main(args: Array[String]): Unit = { M0; M1; diff --git a/test/files/run/Course-2002-03.scala b/test/files/run/Course-2002-03.scala index a4efd7ffa6..a2678544e4 100644 --- a/test/files/run/Course-2002-03.scala +++ b/test/files/run/Course-2002-03.scala @@ -3,7 +3,7 @@ //############################################################################ // $Id$ -module M0 { +object M0 { class Rational(x: Int, y: Int) { def numer = x; def denom = y; @@ -28,7 +28,7 @@ module M0 { //############################################################################ -module M1 { +object M1 { class Rational(x: Int, y: Int) { def numer = x; def denom = y; @@ -55,7 +55,7 @@ module M1 { //############################################################################ -module M2 { +object M2 { class Rational(x: Int, y: Int) { private def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b); private val g = gcd(x, y); @@ -92,7 +92,7 @@ module M2 { //############################################################################ -module M3 { +object M3 { class Rational(x: Int, y: Int) { private def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b); def numer = x / gcd(x, y); @@ -114,7 +114,7 @@ module M3 { //############################################################################ -module M4 { +object M4 { class Rational(x: Int, y: Int) { private def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b); private val g = gcd(x, y); @@ -147,7 +147,7 @@ module M4 { //############################################################################ -module M5 { +object M5 { trait IntSet { def incl(x: Int): IntSet; def contains(x: Int): Boolean; @@ -179,7 +179,7 @@ module M5 { //############################################################################ -module M6 { +object M6 { trait Boolean { def ifThenElse[a](def t: a)(def e: a): a; @@ -195,15 +195,15 @@ module M6 { def <= (x: Boolean): Boolean = ifThenElse[Boolean](x)(new True()); def >= (x: Boolean): Boolean = ifThenElse[Boolean](new True())(x.!); } - class True() extends Boolean { // !!! class -> module + class True() extends Boolean { // !!! class -> object def ifThenElse[a](def t: a)(def e: a): a = t } - class False() extends Boolean { // !!! class -> module + class False() extends Boolean { // !!! class -> object def ifThenElse[a](def t: a)(def e: a): a = e } } //############################################################################ -module M7 { +object M7 { trait Nat { def isZero(): Boolean; def predecessor: Nat; @@ -215,7 +215,7 @@ module M7 { //############################################################################ -module M8 { +object M8 { trait IntSet { def incl(x: Int): IntSet; @@ -244,7 +244,7 @@ module M8 { } } - class Empty extends IntSet { // !!! class Empty() -> module Empty + class Empty extends IntSet { // !!! class Empty() -> object Empty def contains(x: Int): Boolean = false; def incl(x: Int): IntSet = new NonEmpty(x, new Empty, new Empty); def map(f: Int => Int): IntSet = this; @@ -337,7 +337,7 @@ module M8 { //############################################################################ -module M9 { +object M9 { class Rational(x: Int, y: Int) { private def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b); private val g = gcd(x, y); @@ -373,7 +373,7 @@ module M9 { //############################################################################ -module Test { +object Test { def main(args: Array[String]): Unit = { M0; M1; diff --git a/test/files/run/Course-2002-04.scala b/test/files/run/Course-2002-04.scala index 541dc2ac67..61deb96a11 100644 --- a/test/files/run/Course-2002-04.scala +++ b/test/files/run/Course-2002-04.scala @@ -3,7 +3,7 @@ //############################################################################ // $Id$ -module M0 { +object M0 { def quicksort[a] (less : (a,a) => Boolean) (xs : List[a]) : List[a] = { if (xs.isEmpty) @@ -41,7 +41,7 @@ module M0 { //############################################################################ -module M1 { +object M1 { def horner (x : Double, coefs : List[Double]) : Double = { if (coefs.isEmpty) @@ -63,7 +63,7 @@ module M1 { //############################################################################ -module M2 { +object M2 { def dotproduct (v : List[Double], w : List[Double]) : Double = { if (v.isEmpty) @@ -149,7 +149,7 @@ module M2 { //############################################################################ -module Test { +object Test { def main(args: Array[String]): Unit = { M0.test; M1.test; diff --git a/test/files/run/Course-2002-06.scala b/test/files/run/Course-2002-06.scala index d9190d35b5..d044d778d6 100644 --- a/test/files/run/Course-2002-06.scala +++ b/test/files/run/Course-2002-06.scala @@ -145,7 +145,7 @@ class PostScript (filename: String, _width: Double, _height: Double) //############################################################################ -module M0 { +object M0 { /** Define the type of a painter as a function that takes a frame, * draws itself onto it and returns nothing @@ -254,7 +254,7 @@ module M0 { //############################################################################ -module Test { +object Test { def main(args: Array[String]): Unit = { M0.test; () diff --git a/test/files/run/Course-2002-07.scala b/test/files/run/Course-2002-07.scala index 3d1f21b209..2a45805138 100644 --- a/test/files/run/Course-2002-07.scala +++ b/test/files/run/Course-2002-07.scala @@ -3,7 +3,7 @@ //############################################################################ // $Id$ -module M0 { +object M0 { trait Expr { def isNumber: boolean; @@ -66,7 +66,7 @@ module M0 { //############################################################################ -module M1 { +object M1 { trait Expr { def eval: int; @@ -93,7 +93,7 @@ module M1 { //############################################################################ -module M2 { +object M2 { trait Expr; case class Number(n: int) extends Expr; @@ -117,7 +117,7 @@ module M2 { //############################################################################ -module M3 { +object M3 { trait Expr { def eval: int = this match { @@ -142,7 +142,7 @@ module M3 { //############################################################################ -module M4 { +object M4 { def concat[a](xss: List[List[a]]): List[a] = xss match { case List() => List() @@ -180,7 +180,7 @@ module M4 { //############################################################################ -module M5 { +object M5 { def zipFun[a,b](xs:List[a], ys:List[b]):List[Pair[a,b]] = Pair(xs,ys) match { case Pair(List(), _) => List() @@ -215,7 +215,7 @@ module M5 { //############################################################################ -module M6 { +object M6 { def zipFun[a,b](xs:List[a], ys:List[b]):List[Pair[a,b]] = Pair(xs,ys) match { // !!! case Pair(List(), _), Pair(_, List()) => List() @@ -248,7 +248,7 @@ module M6 { //############################################################################ -module M7 { +object M7 { def heads[a](xss: List[List[a]]): List[a] = xss flatMap { case x :: xs => List(x) @@ -292,7 +292,7 @@ module M7 { //############################################################################ -module M8 { +object M8 { def heads[a](xss: List[List[a]]): List[a] = xss.flatMap { y => y match { @@ -338,7 +338,7 @@ module M8 { //############################################################################ -module M9 { +object M9 { trait Expr { def derive(v: Var): Expr = match { @@ -374,7 +374,7 @@ module M9 { //############################################################################ -module MA { +object MA { def lookup[k,v](xs: List[Pair[k,v]], k: k): v = xs match { case List() => error("no value for " + k) @@ -449,7 +449,7 @@ module MA { //############################################################################ -module Utils { +object Utils { private def power0(x: int, y: int): int = if (y == 1) x else if (y % 2 == 0) power0(x*x,y/2) else x*power0(x, y-1); @@ -482,7 +482,7 @@ module Utils { } -module MB { +object MB { import Utils._; @@ -703,7 +703,7 @@ module MB { //############################################################################ -module Test { +object Test { def main(args: Array[String]): unit = { M0.test; M1.test; diff --git a/test/files/run/Course-2002-08.scala b/test/files/run/Course-2002-08.scala index 9cb2bb8701..dad9426d7f 100644 --- a/test/files/run/Course-2002-08.scala +++ b/test/files/run/Course-2002-08.scala @@ -5,7 +5,7 @@ import List._; -module M0 { +object M0 { var x: String = "abc"; var count = 111; @@ -23,7 +23,7 @@ module M0 { //############################################################################ -module M1 { +object M1 { class BankAccount() { private var balance = 0; @@ -87,7 +87,7 @@ module M1 { //############################################################################ -module M2 { +object M2 { def while(def condition: Boolean)(def command: Unit): Unit = if (condition) { @@ -113,7 +113,7 @@ module M2 { //############################################################################ -module M3 { +object M3 { def power (x: Double, exp: Int): Double = { var r = 1.0; @@ -133,7 +133,7 @@ module M3 { //############################################################################ -module M4 { +object M4 { def test = { for (val i <- range(1, 4)) do { System.out.print(i + " ") }; @@ -145,7 +145,7 @@ module M4 { //############################################################################ -module M5 { +object M5 { type Action = () => Unit; @@ -579,7 +579,7 @@ class Main() extends CircuitSimulator() { //############################################################################ -module Test { +object Test { def main(args: Array[String]): Unit = { M0.test; M1.test; diff --git a/test/files/run/Course-2002-09.scala b/test/files/run/Course-2002-09.scala index 2e012fdf35..4238402263 100644 --- a/test/files/run/Course-2002-09.scala +++ b/test/files/run/Course-2002-09.scala @@ -12,7 +12,7 @@ trait Constraint { def dropValue: Unit } -module NoConstraint extends Constraint { +object NoConstraint extends Constraint { def newValue: Unit = error("NoConstraint.newValue"); def dropValue: Unit = error("NoConstraint.dropValue"); } @@ -168,7 +168,7 @@ class Quantity() { //############################################################################ -module M0 { +object M0 { def CFconverter(c: Quantity, f: Quantity) = { val u = new Quantity(); @@ -209,7 +209,7 @@ module M0 { //############################################################################ -module M1 { +object M1 { def constant(x: double): Quantity = { val q = new Quantity(); @@ -250,7 +250,7 @@ module M1 { //############################################################################ -module M2 { +object M2 { val a = new Quantity(); val b = new Quantity(); @@ -298,7 +298,7 @@ module M2 { //############################################################################ -module M3 { +object M3 { def test = { val a = new Quantity(); @@ -324,7 +324,7 @@ module M3 { //############################################################################ -module Test { +object Test { def main(args: Array[String]): Unit = { M0.test; M1.test; diff --git a/test/files/run/Course-2002-10.scala b/test/files/run/Course-2002-10.scala index aabe99ba53..9a292937ca 100644 --- a/test/files/run/Course-2002-10.scala +++ b/test/files/run/Course-2002-10.scala @@ -3,7 +3,7 @@ //############################################################################ // $Id$ -module M0 { +object M0 { def addStream (s1: Stream[int], s2: Stream[int]): Stream[int] = Stream.cons(s1.head + s2.head, addStream(s1.tail, s2.tail)); @@ -20,7 +20,7 @@ module M0 { //############################################################################ -module M1 { +object M1 { def scale(x: double, s: Stream[double]): Stream[double] = s map (e: double => e*x); @@ -92,7 +92,7 @@ module M1 { //############################################################################ -module M2 { +object M2 { class IntIterator(start: int) extends Iterator[int] { var current: int = start; @@ -120,7 +120,7 @@ module M2 { //############################################################################ -module Test { +object Test { def main(args: Array[String]): Unit = { M0.test; M1.test; diff --git a/test/files/run/Course-2002-11.scala b/test/files/run/Course-2002-11.scala index 5a257234c4..c7cae8bb53 100644 --- a/test/files/run/Course-2002-11.scala +++ b/test/files/run/Course-2002-11.scala @@ -5,7 +5,7 @@ import List._; -module Lisp { +object Lisp { trait Data { def elemsToString(): String = toString(); @@ -17,7 +17,7 @@ module Lisp { case _ => " " + cdr.elemsToString(); }) } - case class NIL() extends Data { // !!! use case module + case class NIL() extends Data { // !!! use case object override def toString() = "()"; } case class SYM(name: String) extends Data { @@ -237,7 +237,7 @@ class LispTokenizer(s: String) extends Iterator[String] { //############################################################################ -module M0 { +object M0 { def test = { import Lisp._; @@ -288,7 +288,7 @@ module M0 { //############################################################################ -module Test { +object Test { def main(args: Array[String]): Unit = { M0.test; () diff --git a/test/files/run/Course-2002-13.scala b/test/files/run/Course-2002-13.scala index 0fdb715991..ebdde8bf86 100644 --- a/test/files/run/Course-2002-13.scala +++ b/test/files/run/Course-2002-13.scala @@ -82,7 +82,7 @@ class Interpreter { } -module Terms { +object Terms { val debug = false; @@ -159,7 +159,7 @@ module Terms { import Terms._; -module Programs { +object Programs { case class Clause(lhs: Term, rhs: List[Term]) { def tyvars = @@ -262,7 +262,7 @@ class Parser(s: String) { def all: List[Clause] = if (token equals "") List() else line :: all; } -module Prolog { +object Prolog { def processor: String => Unit = { var program: List[Clause] = List(); @@ -304,7 +304,7 @@ module Prolog { //############################################################################ -module Test { +object Test { def main(args: Array[String]): Unit = { Prolog.process( "sujet(jean).\n" + diff --git a/test/files/run/misc.scala b/test/files/run/misc.scala index dd82d097cd..1468193ab6 100644 --- a/test/files/run/misc.scala +++ b/test/files/run/misc.scala @@ -1,6 +1,6 @@ // $Id$ -module Test { +object Test { def fac(n: Int): Int = if (n < 2) 1 else fac(n - 1) * n; diff --git a/test/files/run/queens.scala b/test/files/run/queens.scala index 2a705c4892..4daa702e29 100644 --- a/test/files/run/queens.scala +++ b/test/files/run/queens.scala @@ -1,6 +1,6 @@ // $Id$ -module M0 { +object M0 { type Placement = List[Int]; def range(lo: Int, hi: Int): List[Int] = @@ -41,7 +41,7 @@ module M0 { } } -module Test { +object Test { def main(args: Array[String]): Unit = { M0.test; () diff --git a/test/neg/S2.scala b/test/neg/S2.scala index 83cc1829a3..47687a916a 100644 --- a/test/neg/S2.scala +++ b/test/neg/S2.scala @@ -7,7 +7,7 @@ ** def t = foo(x, y); ** ^ */ -module M { +object M { def foo[T](x: T, y: T): T = x; class S2() { class Inner() extends S2() {} diff --git a/test/neg/altherr1.scala b/test/neg/altherr1.scala index 69443bfd06..9eb0cc9987 100644 --- a/test/neg/altherr1.scala +++ b/test/neg/altherr1.scala @@ -1,6 +1,6 @@ case class Foo[a](); -module Bug { +object Bug { def foo[a](): Foo[a] = foo[a](); foo() match { case _ => 0 } } diff --git a/test/neg/altherr2.scala b/test/neg/altherr2.scala index 41bcffca36..6ab26526f7 100644 --- a/test/neg/altherr2.scala +++ b/test/neg/altherr2.scala @@ -1,6 +1,6 @@ trait Foo[a]; -module Bug { +object Bug { def foo[a](): Foo[a] = foo[a](); foo()[Int]; } diff --git a/test/neg/altherr3.scala b/test/neg/altherr3.scala index bb40099e1e..a96513e832 100644 --- a/test/neg/altherr3.scala +++ b/test/neg/altherr3.scala @@ -1,6 +1,6 @@ // $Id$ -module bug { +object bug { //########################################################################## diff --git a/test/neg/vincent1.scala b/test/neg/vincent1.scala index 53104be640..6082b271b3 100644 --- a/test/neg/vincent1.scala +++ b/test/neg/vincent1.scala @@ -1,4 +1,4 @@ -module test { +object test { trait A { type T; } diff --git a/test/pos/A.scala b/test/pos/A.scala index 2f7c958ae2..513c8bed45 100644 --- a/test/pos/A.scala +++ b/test/pos/A.scala @@ -1,6 +1,6 @@ trait A extends scala.Object {} -module test { +object test { def x: A = x; diff --git a/test/pos/IntSet.scala b/test/pos/IntSet.scala index cfffc88944..639a099d9a 100644 --- a/test/pos/IntSet.scala +++ b/test/pos/IntSet.scala @@ -4,8 +4,8 @@ trait IntSet { def foreach(f: Int => Unit): Unit; def union(that: IntSet): IntSet; } -module Empty extends IntSet { - def contains(x: Int): Boolean = false; +object Empty extends IntSet { + def contains(x: Int): Boolean = Boolean.False; def incl(x: Int): IntSet = new NonEmpty(x, Empty, Empty); def foreach(f: Int => Unit): Unit = (); def union(that: IntSet): IntSet = that; @@ -26,7 +26,7 @@ class NonEmpty(elem: Int, left: IntSet, right: IntSet) extends IntSet { } def union(that: IntSet): IntSet = (left union (right union that)) incl elem; } -module test { +object test { def main = { val x = Empty incl 1 incl 2; val y = Empty incl 2 incl 3; diff --git a/test/pos/List1.scala b/test/pos/List1.scala index fcc506bccc..6c54f109ce 100644 --- a/test/pos/List1.scala +++ b/test/pos/List1.scala @@ -1,4 +1,4 @@ -module lists { +object lists { trait List[a] { def isEmpty: Boolean; diff --git a/test/pos/S5.scala b/test/pos/S5.scala index 87325b47e4..08f5b2a6eb 100644 --- a/test/pos/S5.scala +++ b/test/pos/S5.scala @@ -25,6 +25,6 @@ abstract class N() { // module body of N } } -module O { +object O { val system = new M() with N() {} } diff --git a/test/pos/S8.scala b/test/pos/S8.scala index e4339bb3f1..50f1df27a2 100644 --- a/test/pos/S8.scala +++ b/test/pos/S8.scala @@ -13,7 +13,7 @@ class S8() { class A() extends a.B() {} class B() {} } -module M { +object M { val x = new S8(); val y: x.a.B = new x.A(); //correct? } diff --git a/test/pos/Y.scala b/test/pos/Y.scala index 425d7fb346..ebef6f9e36 100644 --- a/test/pos/Y.scala +++ b/test/pos/Y.scala @@ -1,4 +1,4 @@ -module test { +object test { def f(x: Object): Object = x.match; diff --git a/test/pos/Z.scala b/test/pos/Z.scala index c19081e68c..c1367e46b9 100644 --- a/test/pos/Z.scala +++ b/test/pos/Z.scala @@ -2,7 +2,7 @@ trait X { val elem: Int = 1 } -module test { +object test { def g(x: X) = x.elem; def f(x: Object) = x.toString(); diff --git a/test/pos/cls.scala b/test/pos/cls.scala index 3a46c306db..54104ae692 100644 --- a/test/pos/cls.scala +++ b/test/pos/cls.scala @@ -8,7 +8,7 @@ class B[Y](y1: Y, y2: Y) extends A[Y, Y](y1, y2) { def g() = f(y1, this); } -module test { +object test { val b: B[Int] = new B[Int](1, 2); val a: A[Int, Int] = b; val a1 = new A(1, "hello"); diff --git a/test/pos/clsrefine.scala b/test/pos/clsrefine.scala index 12f5aa5246..56db9d4c13 100644 --- a/test/pos/clsrefine.scala +++ b/test/pos/clsrefine.scala @@ -15,7 +15,7 @@ trait B extends A { def g() = f(y1, this); } -module test { +object test { val b: B { type Y = Int } = new B { type Y = Int; val y1 = 1, y2 = 1; diff --git a/test/pos/cours1.scala b/test/pos/cours1.scala index 48b5f6504d..2dc3ac6238 100644 --- a/test/pos/cours1.scala +++ b/test/pos/cours1.scala @@ -1,4 +1,4 @@ -module test { +object test { def size = 2; def pi = 3.14159; diff --git a/test/pos/cours2.scala b/test/pos/cours2.scala index 032531b25e..c96f588791 100644 --- a/test/pos/cours2.scala +++ b/test/pos/cours2.scala @@ -1,4 +1,4 @@ -module m1 { +object m1 { def id(x: Int): Double = x; def cube(x: Int): Double = x * x * x; @@ -18,7 +18,7 @@ module m1 { } -module m2 { +object m2 { def id(x: Int): Double = x; def cube(x: Int): Double = x * x * x; @@ -33,7 +33,7 @@ module m2 { def sumReciprocals(a: Int, b: Int): Double = sum(reciprocal, a, b); } -module m3 { +object m3 { def sum(f: Int => Double, a: Int, b: Int): Double = if (a > b) 0 @@ -44,7 +44,7 @@ module m3 { def sumReciprocals(a: Int, b: Int): Double = sum((x => 1.0/x), a, b); } -module m4 { +object m4 { def sum(f: Int => Double) = { def sumF(a: Int, b: Int): Double = @@ -60,7 +60,7 @@ module m4 { sumCubes(1, 10) + sumReciprocals(10, 20); } -module m5 { +object m5 { def sum(f: Int => Double): (Int, Int) => Double = (a, b) => if (a > b) 0 @@ -73,7 +73,7 @@ module m5 { sumCubes(1, 10) + sumReciprocals(10, 20); } -module m6 { +object m6 { def sum(f: Int => Double)(a: Int, b: Int): Double = if (a > b) 0 @@ -86,7 +86,7 @@ module m6 { sumCubes(1, 10) + sumReciprocals(10, 20); } -module m7 { +object m7 { def sum(f: Int => Double)(a: Int, b: Int): Double = { def iter(a: Int, result: Double): Double = @@ -102,7 +102,7 @@ module m7 { sumCubes(1, 10) + sumReciprocals(10, 20); } -module m8 { +object m8 { def product(f: Int => Double)(a: Int, step: Int, b: Int): Double = if (a > b) 1 @@ -111,7 +111,7 @@ module m8 { val pi = 8 * product(x => x * x)(4, 2, 40) / product(x => x * x)(3, 2, 40); } -module m9 { +object m9 { def accumulate[t](combiner: (t, t) => t, nullValue: t, f: Int => t, next: Int => Int) (a: Int, b: Int): t = diff --git a/test/pos/cours2a.scala b/test/pos/cours2a.scala index b888b88a96..9afa703cd7 100644 --- a/test/pos/cours2a.scala +++ b/test/pos/cours2a.scala @@ -1,10 +1,10 @@ -module m1 { +object m1 { def factorial(n: Int): Int = if (n == 0) 1 else n * factorial(n-1); } -module m2 { +object m2 { def factorial(n: Int): Int = { def factIter(n: Int, acc: Int): Int = { diff --git a/test/pos/cours2b.scala b/test/pos/cours2b.scala index edac3ed483..aea7029656 100644 --- a/test/pos/cours2b.scala +++ b/test/pos/cours2b.scala @@ -1,4 +1,4 @@ -module m1 { +object m1 { def gcd(x: Int, y: Int): Int = if (y == 0) x diff --git a/test/pos/cours2c.scala b/test/pos/cours2c.scala index c2e4b221d5..776469e1bb 100644 --- a/test/pos/cours2c.scala +++ b/test/pos/cours2c.scala @@ -1,4 +1,4 @@ -module m1 { +object m1 { def average(x: Double, y: Double) = (x + y)/2; def abs(x: Double): Double = if (x < 0) - x else x; @@ -25,7 +25,7 @@ module m1 { } } -module m2 { +object m2 { def abs(x: Double): Double = if (x < 0) - x else x; def isCloseEnough(x: Double, y: Double) = abs((x - y) / x) < 0.001; diff --git a/test/pos/eta.scala b/test/pos/eta.scala index 67e6c0f080..7d862f67b1 100644 --- a/test/pos/eta.scala +++ b/test/pos/eta.scala @@ -1,4 +1,4 @@ -module test { +object test { def sum(f: Int => Int)(x: Int, y: Int): Int = 0; def g = sum; diff --git a/test/pos/exceptions.scala b/test/pos/exceptions.scala index 4c7ffa35c8..7c376f3aac 100644 --- a/test/pos/exceptions.scala +++ b/test/pos/exceptions.scala @@ -1,6 +1,6 @@ import java.io._; -module test { +object test { //def error[a](x: String):a = new java.lang.RuntimeException(x) throw; diff --git a/test/pos/imports.scala b/test/pos/imports.scala index f13a3a4368..32b7aace62 100644 --- a/test/pos/imports.scala +++ b/test/pos/imports.scala @@ -4,7 +4,7 @@ package test; import java.lang.{System => S} -module test { +object test { import S.out.{print => p, println => print} val foo = 1; @@ -12,7 +12,7 @@ module test { p("hello"); print("world"); S.out.println("!"); S.out.flush(); } -module test1 { +object test1 { import test._; foo } \ No newline at end of file diff --git a/test/pos/lambda.scala b/test/pos/lambda.scala index 27c273cc3c..187b3f9783 100644 --- a/test/pos/lambda.scala +++ b/test/pos/lambda.scala @@ -1,4 +1,4 @@ -module test { +object test { def apply[a,b](f: a => b): a => b = x: a => f(x); diff --git a/test/pos/lambdalift.scala b/test/pos/lambdalift.scala index f780b8e13f..ae5799a6f8 100644 --- a/test/pos/lambdalift.scala +++ b/test/pos/lambdalift.scala @@ -1,6 +1,6 @@ import scala._; -module test { +object test { def f(x: Int) = { def g() = h(); diff --git a/test/pos/lambdalift1.scala b/test/pos/lambdalift1.scala index e4c7b3a801..d9172f51eb 100644 --- a/test/pos/lambdalift1.scala +++ b/test/pos/lambdalift1.scala @@ -1,6 +1,6 @@ import scala._; -module test { +object test { def f[a <: java.lang.Object](x: a) = { def print() = java.lang.System.out.println(x); diff --git a/test/pos/localmodules.scala b/test/pos/localmodules.scala new file mode 100644 index 0000000000..8ed34f455a --- /dev/null +++ b/test/pos/localmodules.scala @@ -0,0 +1,22 @@ +package test; + +object main { + + class a { + + object b { + + trait c {} + def foo(x: c): c = { System.out.println("foo(" + x + ")"); x } + + } + + def bar(x: b.c): a.this.b.c = { b.foo(x); x } + } + + def main(args: Array[String]) = { + val aa = new a; + val xx: aa.b.c = null; + System.out.println(aa.bar(xx)); + } +} diff --git a/test/pos/matthias1.scala b/test/pos/matthias1.scala index 418c2f32be..a923a529fe 100644 --- a/test/pos/matthias1.scala +++ b/test/pos/matthias1.scala @@ -3,7 +3,7 @@ class A() { def foo(x: B) = 0 } } -module test { +object test { def main = { val a = new A(); val b = new a.B(); diff --git a/test/pos/matthias4.scala b/test/pos/matthias4.scala index 751c8b1c88..32200cccd1 100644 --- a/test/pos/matthias4.scala +++ b/test/pos/matthias4.scala @@ -1,19 +1,19 @@ /* -module A requires B { +object A requires B { B.X getX() { return B.getX(); } void setX(B.X x) {} } -module B { +object B { class X {} X getX() { return new X(); } void setX(X x) {} } -module C requires B { - module A; +object C requires B { + object A; void test() { A.setX(B.getX()); } @@ -23,8 +23,8 @@ module C requires B { trait _a extends Object with _b { val a: _a; val A: A; - type A <: a.AModule; - trait AModule { + type A <: a.AObject; + trait AObject { def getX(): B.X; def setX(x: B.X): Unit; } @@ -32,7 +32,7 @@ trait _a extends Object with _b { abstract class a() extends Object with _a with _b { val a: this.type = this; val A: A = new A(); - class A() extends AModule { + class A() extends AObject { def getX(): B.X = B.getX(); def setX(x: B.X) = B.setX(x); } @@ -41,8 +41,8 @@ abstract class a() extends Object with _a with _b { trait _b { val b: _b; val B: B; - type B <: b.BModule; - trait BModule { + type B <: b.BObject; + trait BObject { type X; def getX(): X; def setX(x: X): Unit; @@ -51,7 +51,7 @@ trait _b { abstract class b() extends Object with _b { val b: this.type = this; val B: B = new B(); - class B() extends BModule { + class B() extends BObject { class X() {} def getX(): X = new X(); def setX(x: X) = (); @@ -61,13 +61,13 @@ abstract class b() extends Object with _b { trait _m { val m: _m; val M: M; - type M <: m.MModule; - trait MModule {} + type M <: m.MObject; + trait MObject {} } abstract class m() extends Object with _m with _b { val m: this.type = this; val M: M = new M(); - class M() extends MModule with a() with Linker() { + class M() extends MObject with a() with Linker() { def test() = { val x: B.X = B.getX(); A.setX(x); diff --git a/test/pos/maxim1.scala b/test/pos/maxim1.scala index 01a7c05e9a..58916beb8a 100644 --- a/test/pos/maxim1.scala +++ b/test/pos/maxim1.scala @@ -1,4 +1,4 @@ -module test { +object test { def f(x: Int)(y: Int) = x + y; def y: Int => Int = f(2); def main = y(1); diff --git a/test/pos/modules.scala b/test/pos/modules.scala index d916d7fd60..8168a42d3c 100644 --- a/test/pos/modules.scala +++ b/test/pos/modules.scala @@ -1,8 +1,8 @@ package scala { - module a { + object a { - module b { + object b { trait c {} def foo(x: c): c = bar(x) diff --git a/test/pos/modules1.scala b/test/pos/modules1.scala index 71c4bf8bd4..3da14af4fe 100644 --- a/test/pos/modules1.scala +++ b/test/pos/modules1.scala @@ -1,14 +1,14 @@ package scala { - module a { + object a { - module b { + object b { trait c {} def foo(x: c): c = bar(x) } - def bar(x: b.c): a.b.c = x + def bar(x: b.c): a.b.c = { b.foo(x); x } } } diff --git a/test/pos/moduletrans.scala b/test/pos/moduletrans.scala index 953ce4ee6c..51538417ed 100644 --- a/test/pos/moduletrans.scala +++ b/test/pos/moduletrans.scala @@ -1,4 +1,4 @@ -module m1 { +object m1 { class m() { def f() = 5 diff --git a/test/pos/null.scala b/test/pos/null.scala index 54a2c0f995..59f88ee0e0 100644 --- a/test/pos/null.scala +++ b/test/pos/null.scala @@ -1,3 +1,3 @@ -module M { +object M { val x: Boolean = null == null; } \ No newline at end of file diff --git a/test/pos/partialfun.scala b/test/pos/partialfun.scala index 1f27d099e4..e6af633811 100644 --- a/test/pos/partialfun.scala +++ b/test/pos/partialfun.scala @@ -1,4 +1,4 @@ -module partialfun { +object partialfun { def applyPartial[b](f: PartialFunction[Option[String], b])(x: Option[String]) = if (f.isDefinedAt(x)) f(x) else ""; diff --git a/test/pos/patterns.scala b/test/pos/patterns.scala index 18ffec5025..48c068c618 100644 --- a/test/pos/patterns.scala +++ b/test/pos/patterns.scala @@ -2,7 +2,7 @@ trait Option[a] {} case class Some[a](x: a) extends Option[a]; case class None[a] extends Option[a]; -module test { +object test { def println(str: String): Unit = java.lang.System.out.println(str); diff --git a/test/pos/patterns2.scala b/test/pos/patterns2.scala index 023aaf44af..dab73a98fc 100644 --- a/test/pos/patterns2.scala +++ b/test/pos/patterns2.scala @@ -3,7 +3,7 @@ case class Choice(a: Option, b: Option) extends Option; case class Some(x: java.lang.String) extends Option; case class None extends Option; -module test { +object test { def f(opt: Option) = opt match { case Choice(Some("one"), Some(x)) => 1; diff --git a/test/pos/philippe1.scala b/test/pos/philippe1.scala index d079c5974a..3cace0e116 100644 --- a/test/pos/philippe1.scala +++ b/test/pos/philippe1.scala @@ -1,4 +1,4 @@ -module test { +object test { def id[a](xs: Array[a]): Array[a] = xs; def main(args: Array[String]): Unit = { diff --git a/test/pos/philippe3.scala b/test/pos/philippe3.scala index d99ec41f52..9442583997 100644 --- a/test/pos/philippe3.scala +++ b/test/pos/philippe3.scala @@ -29,12 +29,12 @@ case class D6() extends C() {} case class D7() extends C() with U; case class D8() extends C() with U {} -module M1; -module M2 {} -module M5 extends C(); -module M6 extends C() {} -module M7 extends C() with U; -module M8 extends C() with U {} +object M1; +object M2 {} +object M5 extends C(); +object M6 extends C() {} +object M7 extends C() with U; +object M8 extends C() with U {} diff --git a/test/pos/reftest.scala b/test/pos/reftest.scala index 27083bd2cc..f709f70897 100644 --- a/test/pos/reftest.scala +++ b/test/pos/reftest.scala @@ -1,4 +1,4 @@ import scala._; -module test { +object test { val x: Ref[Int] = new Ref(1); } \ No newline at end of file diff --git a/test/pos/sort1.scala b/test/pos/sort1.scala index 0a75a87272..c2895fe535 100644 --- a/test/pos/sort1.scala +++ b/test/pos/sort1.scala @@ -1,4 +1,4 @@ -module test { +object test { type String = java.lang.String; diff --git a/test/pos/sqrt.scala b/test/pos/sqrt.scala index f6a53824b4..5ad1718619 100644 --- a/test/pos/sqrt.scala +++ b/test/pos/sqrt.scala @@ -1,4 +1,4 @@ -module test { +object test { def abs(x: Double) = if (x >= 0) x else 0 - x; diff --git a/test/pos/strings.scala b/test/pos/strings.scala index 75bf23f5e3..3bf40e3dda 100644 --- a/test/pos/strings.scala +++ b/test/pos/strings.scala @@ -1,5 +1,5 @@ // martin 1-3-2002: it seems there is a problem with the way Serializable is loaded. -module test { +object test { def f() = "hello".concat("world"); diff --git a/test/pos/test1.scala b/test/pos/test1.scala index 6e8e4f98a7..a36d2436ec 100644 --- a/test/pos/test1.scala +++ b/test/pos/test1.scala @@ -1,4 +1,4 @@ -module test { +object test { def f() = 5; diff --git a/test/pos/test2.scala b/test/pos/test2.scala index 4c73e0a10b..fe36d07f1b 100644 --- a/test/pos/test2.scala +++ b/test/pos/test2.scala @@ -1,5 +1,5 @@ import scala._; -module test2 { +object test2 { def f(x: Int): Int = 'a'; def g(x: Int) = f(f(x)); } \ No newline at end of file diff --git a/test/pos/test4.scala b/test/pos/test4.scala index 0bbb6f97a0..48949b7a7f 100644 --- a/test/pos/test4.scala +++ b/test/pos/test4.scala @@ -2,7 +2,7 @@ trait C {} trait D {} trait E {} -module test { +object test { def c: C = c; def d: D = d; def e: E = e; @@ -22,7 +22,7 @@ class O[X]() { val j:I[X] = null; } -module o extends O[C]() { +object o extends O[C]() { def main = { val s: S = null; diff --git a/test/pos/test4a.scala b/test/pos/test4a.scala index 0d653c5012..ada0ba4e5f 100644 --- a/test/pos/test4a.scala +++ b/test/pos/test4a.scala @@ -7,7 +7,7 @@ class O[X]() { val j:I[X] = null; } -module o extends O[C]() { +object o extends O[C]() { def c: C = c; def main = { o.j.foo(c); diff --git a/test/pos/test4refine.scala b/test/pos/test4refine.scala index ad68bc891a..6710962934 100644 --- a/test/pos/test4refine.scala +++ b/test/pos/test4refine.scala @@ -2,7 +2,7 @@ trait C {} trait D {} trait E {} -module test { +object test { def c: C = c; def d: D = d; def e: E = e; @@ -25,7 +25,7 @@ abstract class O() { val j:I { type Y = X } = null; } -module o extends O() { +object o extends O() { type X = C; def main = { diff --git a/test/pos/test5.scala b/test/pos/test5.scala index 08f91650da..bc3a17c9be 100644 --- a/test/pos/test5.scala +++ b/test/pos/test5.scala @@ -1,6 +1,6 @@ import scala._; -module test { +object test { trait F[If] {} diff --git a/test/pos/test5refine.scala b/test/pos/test5refine.scala index 7efbf5a3f1..95670faa05 100644 --- a/test/pos/test5refine.scala +++ b/test/pos/test5refine.scala @@ -1,6 +1,6 @@ import scala._; -module test { +object test { abstract trait F { type If; } diff --git a/test/pos/valdefs.scala b/test/pos/valdefs.scala index b05edbf7b2..f9150ea509 100644 --- a/test/pos/valdefs.scala +++ b/test/pos/valdefs.scala @@ -1,4 +1,4 @@ -module test { +object test { abstract class Base() { val x: String; diff --git a/test/pos/vincent.scala b/test/pos/vincent.scala new file mode 100644 index 0000000000..eed25eb84c --- /dev/null +++ b/test/pos/vincent.scala @@ -0,0 +1,21 @@ +object test { + + trait A { type T; } + + trait B { type T; } + + /** def functor(x: A): B { type T = x.T } */ + abstract class functor() { + val arg: A; + val res: B { type T = arg.T } = + new B { type T = arg.T; }; + } + + val a = new A { type T = String }; + /** val b: B { type T = String } = functor(a) */ + val b: B { type T = String } = { + val tmp = new functor() { val arg = a }; + tmp.res + } + +} -- cgit v1.2.3