summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2004-01-15 12:14:03 +0000
committerMartin Odersky <odersky@gmail.com>2004-01-15 12:14:03 +0000
commitde408cadfb612d04e9adfe049a2bdf9f71da5bd5 (patch)
treed2b471cdfd6e97b00e79b1eb6d6ff19faae073a8
parent0362d6e25548f8f5c644af8eca34c6c7de47f246 (diff)
downloadscala-de408cadfb612d04e9adfe049a2bdf9f71da5bd5.tar.gz
scala-de408cadfb612d04e9adfe049a2bdf9f71da5bd5.tar.bz2
scala-de408cadfb612d04e9adfe049a2bdf9f71da5bd5.zip
*** empty log message ***
-rw-r--r--test/files/pos/List1.scala45
-rw-r--r--test/files/pos/clsrefine.scala33
-rw-r--r--test/files/pos/compound.scala9
-rw-r--r--test/files/pos/matthias3.scala13
-rw-r--r--test/files/pos/matthias5.scala12
-rw-r--r--test/files/pos/refine.scala6
-rw-r--r--test/files/pos/test4refine.scala49
-rw-r--r--test/files/pos/test5refine.scala75
-rw-r--r--test/files/pos/vincent.scala21
-rw-r--r--test/pos/List1.scala45
-rw-r--r--test/pos/clsrefine.scala33
-rw-r--r--test/pos/compound.scala9
-rw-r--r--test/pos/matthias3.scala13
-rw-r--r--test/pos/matthias5.scala12
-rw-r--r--test/pos/refine.scala6
-rw-r--r--test/pos/test4refine.scala49
-rw-r--r--test/pos/test5refine.scala75
-rw-r--r--test/pos/vincent.scala21
18 files changed, 526 insertions, 0 deletions
diff --git a/test/files/pos/List1.scala b/test/files/pos/List1.scala
new file mode 100644
index 0000000000..f0fce9501f
--- /dev/null
+++ b/test/files/pos/List1.scala
@@ -0,0 +1,45 @@
+object lists {
+
+ trait List[a] {
+ def isEmpty: Boolean;
+ def head: a;
+ def tail: List[a];
+ def prepend(x: a) = Cons[a](x, this);
+ }
+
+ def Nil[a] = new List[a] {
+ def isEmpty: Boolean = true;
+ def head = error("head of Nil");
+ def tail = error("tail of Nil");
+ }
+
+ def Cons[a](x: a, xs: List[a]): List[a] = new List[a] {
+ def isEmpty = false;
+ def head = x;
+ def tail = xs;
+ }
+
+ def foo = {
+ val intnil = Nil[Int];
+ val intlist = intnil.prepend(1).prepend(1+1);
+ val x: Int = intlist.head;
+ val strnil = Nil[String];
+ val strlist = strnil.prepend("A").prepend("AA");
+ val y: String = strlist.head;
+ ()
+ }
+
+ class IntList() extends List[Int] {
+ def isEmpty: Boolean = false;
+ def head: Int = 1;
+ def foo: List[Int] { def isEmpty: Boolean; def head: Int; def tail: List[Int] } = Nil[Int];
+ def tail0: List[Int] = foo.prepend(1).prepend(1+1);
+ def tail: List[Int] = Nil[Int].prepend(1).prepend(1+1);
+ }
+
+ def foo2 = {
+ val il1 = new IntList();
+ val il2 = il1.prepend(1).prepend(2);
+ ()
+ }
+}
diff --git a/test/files/pos/clsrefine.scala b/test/files/pos/clsrefine.scala
new file mode 100644
index 0000000000..56db9d4c13
--- /dev/null
+++ b/test/files/pos/clsrefine.scala
@@ -0,0 +1,33 @@
+import scala._;
+
+package scalac.util {
+
+trait A {
+ type X1, X2;
+ val x1: X1, x2: X2;
+}
+trait B extends A {
+ type Y;
+ val y1: Y, y2: Y;
+ type X1 = Y, X2 = Y;
+ val x1 = y1, x2 = y2;
+ def f(x: Y, xs: B): Unit = {}
+ def g() = f(y1, this);
+}
+
+object test {
+ val b: B { type Y = Int } = new B {
+ type Y = Int;
+ val y1 = 1, y2 = 1;
+ }
+ val a: A { type X1 = Int, X2 = Int } = b;
+ val a1 = new A {
+ type X1 = Int, X2 = String;
+ val x1 = 1, x2 = "hello"
+ }
+ val b1 = new B {
+ type Y = Any;
+ val y1 = 1, y2 = "hello";
+ }
+}
+} \ No newline at end of file
diff --git a/test/files/pos/compound.scala b/test/files/pos/compound.scala
new file mode 100644
index 0000000000..60890f9102
--- /dev/null
+++ b/test/files/pos/compound.scala
@@ -0,0 +1,9 @@
+abstract class A { type T }
+
+abstract class B { val xz: Any }
+
+abstract class Test {
+ var yy: A with B { type T; val xz: T } = null;
+ var xx: A with B { type T; val xz: T } = null;
+ xx = yy;
+}
diff --git a/test/files/pos/matthias3.scala b/test/files/pos/matthias3.scala
new file mode 100644
index 0000000000..6e86afeca6
--- /dev/null
+++ b/test/files/pos/matthias3.scala
@@ -0,0 +1,13 @@
+
+abstract class A() {
+ val y: A;
+}
+class B() extends A() {
+ val x = this;
+ val y: x.type = x;
+}
+abstract class C() {
+ val b: B = new B();
+ val a: A { val y: b.type };
+}
+
diff --git a/test/files/pos/matthias5.scala b/test/files/pos/matthias5.scala
new file mode 100644
index 0000000000..0dcb7f833d
--- /dev/null
+++ b/test/files/pos/matthias5.scala
@@ -0,0 +1,12 @@
+abstract class A() {
+ val y: A;
+}
+class B() extends A() {
+ val x = this;
+ val y: x.type = x;
+}
+abstract class C() {
+ val b: B = new B();
+ val a: A { val y: b.type };
+}
+
diff --git a/test/files/pos/refine.scala b/test/files/pos/refine.scala
new file mode 100644
index 0000000000..255621ad43
--- /dev/null
+++ b/test/files/pos/refine.scala
@@ -0,0 +1,6 @@
+object test {
+
+ val x: Object { def toString(): String } = new Object {
+ override def toString(): String = "1";
+ }
+}
diff --git a/test/files/pos/test4refine.scala b/test/files/pos/test4refine.scala
new file mode 100644
index 0000000000..6710962934
--- /dev/null
+++ b/test/files/pos/test4refine.scala
@@ -0,0 +1,49 @@
+trait C {}
+trait D {}
+trait E {}
+
+object test {
+ def c: C = c;
+ def d: D = d;
+ def e: E = e;
+}
+
+import test._;
+
+trait S extends o.I {
+ type Y = D;
+ def bar: E = foo(c,d);
+}
+
+abstract class O() {
+ type X;
+ abstract trait I {
+ type Y;
+ def foo(x: X, y: Y): E = e;
+ }
+ val i:I { type Y = E } = null;
+ val j:I { type Y = X } = null;
+}
+
+object o extends O() {
+ type X = C;
+
+ def main = {
+ val s: S = null;
+ import s._;
+ foo(c,d);
+ o.i.foo(c,e);
+ o.j.foo(c,c);
+ bar
+ }
+}
+
+class Main() {
+ val s: S = null;
+ import s._;
+ foo(c,d);
+ o.i.foo(c,e);
+ o.j.foo(c,c);
+ bar;
+}
+
diff --git a/test/files/pos/test5refine.scala b/test/files/pos/test5refine.scala
new file mode 100644
index 0000000000..95670faa05
--- /dev/null
+++ b/test/files/pos/test5refine.scala
@@ -0,0 +1,75 @@
+import scala._;
+
+object test {
+
+ abstract trait F { type If; }
+
+ def f[Jf](h: Jf):F { type If = Jf } = f[Jf](h);
+
+ abstract trait G { type Ig; }
+
+ def g[Jg](h: Jg):G { type Ig = Jg } = g[Jg](h);
+
+ abstract class M() {
+ type P;
+ abstract class I() {
+ type X;
+
+ // Methods to check the type X and P as seen from instances of I
+ def chk_ix(x: X): Unit = {}
+ def chk_ip(p: P): Unit = {}
+
+ // Value with type X as seen from instances of I
+ def val_ix: X = val_ix;
+ }
+
+ val i: I { type X = G { type Ig = P } } = null;
+
+ // Values with types P and i.X as seen from instances of M
+ def val_mp: P = val_mp;
+ def val_mix: G { type Ig = P } = g[P](val_mp);
+ }
+
+ abstract class N() extends M() {
+ type Q;
+ type P = F { type If = Q };
+ val j:J { type Y = G { type Ig = Q } } = null;
+
+ abstract class J() extends I() {
+ type Y;
+ type X = G { type Ig = Y; };
+ // Values with types Y and X as seen from instances of J
+ def val_jy: Y = val_jy;
+ def val_jx: G { type Ig = Y; } = g[Y](val_jy);
+
+ // Check type P
+ chk_ip(val_mp);
+ chk_ip(val_np);
+ }
+
+ // Values with types Q, X.P, i.X, j.Y and j.X as seen from instances of N
+ def val_nq: Q = val_nq;
+ def val_np: F { type If = Q } = f[Q](val_nq);
+ def val_nix: G { type Ig = F { type If = Q } } = g[F { type If = Q }](val_np);
+ def val_njy: G { type Ig = Q; } = g[Q](val_nq);
+ def val_njx: G { type Ig = G { type Ig = Q }} = g[G { type Ig = Q; }](val_njy);
+
+ // Check type i.P
+ i.chk_ip(val_mp);
+ i.chk_ip(val_np);
+
+ // Check type j.P
+ j.chk_ip(val_mp);
+ j.chk_ip(val_np);
+
+ // Check type i.X
+ i.chk_ix(i.val_ix);
+ i.chk_ix(val_mix);
+ i.chk_ix(val_nix);
+
+ // Check j.X
+ j.chk_ix(j.val_ix);
+ j.chk_ix(j.val_jx);
+ j.chk_ix(val_njx);
+ }
+} \ No newline at end of file
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/pos/List1.scala b/test/pos/List1.scala
new file mode 100644
index 0000000000..f0fce9501f
--- /dev/null
+++ b/test/pos/List1.scala
@@ -0,0 +1,45 @@
+object lists {
+
+ trait List[a] {
+ def isEmpty: Boolean;
+ def head: a;
+ def tail: List[a];
+ def prepend(x: a) = Cons[a](x, this);
+ }
+
+ def Nil[a] = new List[a] {
+ def isEmpty: Boolean = true;
+ def head = error("head of Nil");
+ def tail = error("tail of Nil");
+ }
+
+ def Cons[a](x: a, xs: List[a]): List[a] = new List[a] {
+ def isEmpty = false;
+ def head = x;
+ def tail = xs;
+ }
+
+ def foo = {
+ val intnil = Nil[Int];
+ val intlist = intnil.prepend(1).prepend(1+1);
+ val x: Int = intlist.head;
+ val strnil = Nil[String];
+ val strlist = strnil.prepend("A").prepend("AA");
+ val y: String = strlist.head;
+ ()
+ }
+
+ class IntList() extends List[Int] {
+ def isEmpty: Boolean = false;
+ def head: Int = 1;
+ def foo: List[Int] { def isEmpty: Boolean; def head: Int; def tail: List[Int] } = Nil[Int];
+ def tail0: List[Int] = foo.prepend(1).prepend(1+1);
+ def tail: List[Int] = Nil[Int].prepend(1).prepend(1+1);
+ }
+
+ def foo2 = {
+ val il1 = new IntList();
+ val il2 = il1.prepend(1).prepend(2);
+ ()
+ }
+}
diff --git a/test/pos/clsrefine.scala b/test/pos/clsrefine.scala
new file mode 100644
index 0000000000..56db9d4c13
--- /dev/null
+++ b/test/pos/clsrefine.scala
@@ -0,0 +1,33 @@
+import scala._;
+
+package scalac.util {
+
+trait A {
+ type X1, X2;
+ val x1: X1, x2: X2;
+}
+trait B extends A {
+ type Y;
+ val y1: Y, y2: Y;
+ type X1 = Y, X2 = Y;
+ val x1 = y1, x2 = y2;
+ def f(x: Y, xs: B): Unit = {}
+ def g() = f(y1, this);
+}
+
+object test {
+ val b: B { type Y = Int } = new B {
+ type Y = Int;
+ val y1 = 1, y2 = 1;
+ }
+ val a: A { type X1 = Int, X2 = Int } = b;
+ val a1 = new A {
+ type X1 = Int, X2 = String;
+ val x1 = 1, x2 = "hello"
+ }
+ val b1 = new B {
+ type Y = Any;
+ val y1 = 1, y2 = "hello";
+ }
+}
+} \ No newline at end of file
diff --git a/test/pos/compound.scala b/test/pos/compound.scala
new file mode 100644
index 0000000000..60890f9102
--- /dev/null
+++ b/test/pos/compound.scala
@@ -0,0 +1,9 @@
+abstract class A { type T }
+
+abstract class B { val xz: Any }
+
+abstract class Test {
+ var yy: A with B { type T; val xz: T } = null;
+ var xx: A with B { type T; val xz: T } = null;
+ xx = yy;
+}
diff --git a/test/pos/matthias3.scala b/test/pos/matthias3.scala
new file mode 100644
index 0000000000..6e86afeca6
--- /dev/null
+++ b/test/pos/matthias3.scala
@@ -0,0 +1,13 @@
+
+abstract class A() {
+ val y: A;
+}
+class B() extends A() {
+ val x = this;
+ val y: x.type = x;
+}
+abstract class C() {
+ val b: B = new B();
+ val a: A { val y: b.type };
+}
+
diff --git a/test/pos/matthias5.scala b/test/pos/matthias5.scala
new file mode 100644
index 0000000000..0dcb7f833d
--- /dev/null
+++ b/test/pos/matthias5.scala
@@ -0,0 +1,12 @@
+abstract class A() {
+ val y: A;
+}
+class B() extends A() {
+ val x = this;
+ val y: x.type = x;
+}
+abstract class C() {
+ val b: B = new B();
+ val a: A { val y: b.type };
+}
+
diff --git a/test/pos/refine.scala b/test/pos/refine.scala
new file mode 100644
index 0000000000..255621ad43
--- /dev/null
+++ b/test/pos/refine.scala
@@ -0,0 +1,6 @@
+object test {
+
+ val x: Object { def toString(): String } = new Object {
+ override def toString(): String = "1";
+ }
+}
diff --git a/test/pos/test4refine.scala b/test/pos/test4refine.scala
new file mode 100644
index 0000000000..6710962934
--- /dev/null
+++ b/test/pos/test4refine.scala
@@ -0,0 +1,49 @@
+trait C {}
+trait D {}
+trait E {}
+
+object test {
+ def c: C = c;
+ def d: D = d;
+ def e: E = e;
+}
+
+import test._;
+
+trait S extends o.I {
+ type Y = D;
+ def bar: E = foo(c,d);
+}
+
+abstract class O() {
+ type X;
+ abstract trait I {
+ type Y;
+ def foo(x: X, y: Y): E = e;
+ }
+ val i:I { type Y = E } = null;
+ val j:I { type Y = X } = null;
+}
+
+object o extends O() {
+ type X = C;
+
+ def main = {
+ val s: S = null;
+ import s._;
+ foo(c,d);
+ o.i.foo(c,e);
+ o.j.foo(c,c);
+ bar
+ }
+}
+
+class Main() {
+ val s: S = null;
+ import s._;
+ foo(c,d);
+ o.i.foo(c,e);
+ o.j.foo(c,c);
+ bar;
+}
+
diff --git a/test/pos/test5refine.scala b/test/pos/test5refine.scala
new file mode 100644
index 0000000000..95670faa05
--- /dev/null
+++ b/test/pos/test5refine.scala
@@ -0,0 +1,75 @@
+import scala._;
+
+object test {
+
+ abstract trait F { type If; }
+
+ def f[Jf](h: Jf):F { type If = Jf } = f[Jf](h);
+
+ abstract trait G { type Ig; }
+
+ def g[Jg](h: Jg):G { type Ig = Jg } = g[Jg](h);
+
+ abstract class M() {
+ type P;
+ abstract class I() {
+ type X;
+
+ // Methods to check the type X and P as seen from instances of I
+ def chk_ix(x: X): Unit = {}
+ def chk_ip(p: P): Unit = {}
+
+ // Value with type X as seen from instances of I
+ def val_ix: X = val_ix;
+ }
+
+ val i: I { type X = G { type Ig = P } } = null;
+
+ // Values with types P and i.X as seen from instances of M
+ def val_mp: P = val_mp;
+ def val_mix: G { type Ig = P } = g[P](val_mp);
+ }
+
+ abstract class N() extends M() {
+ type Q;
+ type P = F { type If = Q };
+ val j:J { type Y = G { type Ig = Q } } = null;
+
+ abstract class J() extends I() {
+ type Y;
+ type X = G { type Ig = Y; };
+ // Values with types Y and X as seen from instances of J
+ def val_jy: Y = val_jy;
+ def val_jx: G { type Ig = Y; } = g[Y](val_jy);
+
+ // Check type P
+ chk_ip(val_mp);
+ chk_ip(val_np);
+ }
+
+ // Values with types Q, X.P, i.X, j.Y and j.X as seen from instances of N
+ def val_nq: Q = val_nq;
+ def val_np: F { type If = Q } = f[Q](val_nq);
+ def val_nix: G { type Ig = F { type If = Q } } = g[F { type If = Q }](val_np);
+ def val_njy: G { type Ig = Q; } = g[Q](val_nq);
+ def val_njx: G { type Ig = G { type Ig = Q }} = g[G { type Ig = Q; }](val_njy);
+
+ // Check type i.P
+ i.chk_ip(val_mp);
+ i.chk_ip(val_np);
+
+ // Check type j.P
+ j.chk_ip(val_mp);
+ j.chk_ip(val_np);
+
+ // Check type i.X
+ i.chk_ix(i.val_ix);
+ i.chk_ix(val_mix);
+ i.chk_ix(val_nix);
+
+ // Check j.X
+ j.chk_ix(j.val_ix);
+ j.chk_ix(j.val_jx);
+ j.chk_ix(val_njx);
+ }
+} \ No newline at end of file
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
+ }
+
+}