summaryrefslogtreecommitdiff
path: root/test/neg
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2003-03-06 19:14:59 +0000
committerMartin Odersky <odersky@gmail.com>2003-03-06 19:14:59 +0000
commita16dd265fddd7da26564109f4026fb1d12c1071a (patch)
tree702ba02d30d68d21d51ac5c83f31b448cd654ce1 /test/neg
parentbcc3899778ce607df11b471a641493037a8c962f (diff)
downloadscala-a16dd265fddd7da26564109f4026fb1d12c1071a.tar.gz
scala-a16dd265fddd7da26564109f4026fb1d12c1071a.tar.bz2
scala-a16dd265fddd7da26564109f4026fb1d12c1071a.zip
*** empty log message ***
Diffstat (limited to 'test/neg')
-rw-r--r--test/neg/S2.scala19
-rw-r--r--test/neg/S4.scala11
-rw-r--r--test/neg/S6.scala12
-rw-r--r--test/neg/S7.scala7
-rw-r--r--test/neg/vincent.scala21
-rw-r--r--test/neg/vincent1.scala17
6 files changed, 87 insertions, 0 deletions
diff --git a/test/neg/S2.scala b/test/neg/S2.scala
new file mode 100644
index 0000000000..83cc1829a3
--- /dev/null
+++ b/test/neg/S2.scala
@@ -0,0 +1,19 @@
+/* I was wondering for a long time what types x and y have;
+** the compiler claims: z.Inner (see commented out line)
+** This is strange because z is not in scope.
+** Furthermore, compilation of this class yields the message: (why?)
+**
+** S2.scala:16: illegal cyclic reference involving value t
+** def t = foo(x, y);
+** ^
+*/
+module M {
+ def foo[T](x: T, y: T): T = x;
+ class S2() {
+ class Inner() extends S2() {}
+ def x = { val z = new S2(); new z.Inner(); }
+ def y = { val z = new S2(); new z.Inner(); }
+ def t = foo(x, y);
+ //def testType: Inner = x;
+ }
+}
diff --git a/test/neg/S4.scala b/test/neg/S4.scala
new file mode 100644
index 0000000000..4f7941082f
--- /dev/null
+++ b/test/neg/S4.scala
@@ -0,0 +1,11 @@
+/* This one compiles, but even if we would have dependent
+** constructor types, it would be not sound.
+*/
+class S4(a: Other) extends a.Inner() {
+ def foo(x: a.Inner) = x;
+ val b = new Other();
+ foo(new S4(b))
+}
+class Other() {
+ class Inner() {}
+}
diff --git a/test/neg/S6.scala b/test/neg/S6.scala
new file mode 100644
index 0000000000..dfe53d22bd
--- /dev/null
+++ b/test/neg/S6.scala
@@ -0,0 +1,12 @@
+/* This program puts the compiler into an endless loop
+*/
+trait T1 {
+ type T;
+}
+trait T2 {
+ type S;
+ type T <: S;
+}
+abstract class S6() extends T1 with T2 {
+ type S <: T;
+}
diff --git a/test/neg/S7.scala b/test/neg/S7.scala
new file mode 100644
index 0000000000..ecb801b9dc
--- /dev/null
+++ b/test/neg/S7.scala
@@ -0,0 +1,7 @@
+/* Another example for a non-terminating compiler run.
+*/
+class S7[T]() {
+ val a: S7[T] = this;
+ class A() extends a.C() {}
+ class C() extends a.A() {}
+}
diff --git a/test/neg/vincent.scala b/test/neg/vincent.scala
new file mode 100644
index 0000000000..0af526d6aa
--- /dev/null
+++ b/test/neg/vincent.scala
@@ -0,0 +1,21 @@
+module test {
+
+ trait A { type T; }
+
+ trait B { type T; }
+
+ /** def functor(x: A): B with { type T = x.T } */
+ abstract class functor() {
+ val arg: A;
+ val res: B with { type T = arg.T } =
+ new B with { type T = arg.T; };
+ }
+
+ val a = new A with { type T = String };
+ /** val b: B with { type T = String } = functor(a) */
+ val b: B with { type T = String } = {
+ val tmp = new functor() with { val arg = a };
+ tmp.res
+ }
+
+}
diff --git a/test/neg/vincent1.scala b/test/neg/vincent1.scala
new file mode 100644
index 0000000000..afcb9a94f4
--- /dev/null
+++ b/test/neg/vincent1.scala
@@ -0,0 +1,17 @@
+module test {
+
+ trait A { type T; }
+
+ trait B { type T; }
+
+ def functor(x: A): B with { type T = x.T } =
+ new B with {
+ type T = x.T;
+ };
+
+ val a = new A with { type T = String };
+ val b = functor(a);
+
+ val s: b.T = "coucou";
+
+}