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/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 +++++++++++++++++++++ 46 files changed, 122 insertions(+), 79 deletions(-) create mode 100644 test/files/pos/localmodules.scala create mode 100644 test/files/pos/vincent.scala (limited to 'test/files/pos') 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 + } + +} -- cgit v1.2.3