diff options
Diffstat (limited to 'test/files/neg')
-rw-r--r-- | test/files/neg/S2.scala | 19 | ||||
-rw-r--r-- | test/files/neg/S4.scala | 11 | ||||
-rw-r--r-- | test/files/neg/S6.scala | 12 | ||||
-rw-r--r-- | test/files/neg/S7.scala | 7 | ||||
-rw-r--r-- | test/files/neg/vincent.scala | 21 | ||||
-rw-r--r-- | test/files/neg/vincent1.scala | 17 |
6 files changed, 87 insertions, 0 deletions
diff --git a/test/files/neg/S2.scala b/test/files/neg/S2.scala new file mode 100644 index 0000000000..83cc1829a3 --- /dev/null +++ b/test/files/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/files/neg/S4.scala b/test/files/neg/S4.scala new file mode 100644 index 0000000000..4f7941082f --- /dev/null +++ b/test/files/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/files/neg/S6.scala b/test/files/neg/S6.scala new file mode 100644 index 0000000000..dfe53d22bd --- /dev/null +++ b/test/files/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/files/neg/S7.scala b/test/files/neg/S7.scala new file mode 100644 index 0000000000..ecb801b9dc --- /dev/null +++ b/test/files/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/files/neg/vincent.scala b/test/files/neg/vincent.scala new file mode 100644 index 0000000000..0af526d6aa --- /dev/null +++ b/test/files/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/files/neg/vincent1.scala b/test/files/neg/vincent1.scala new file mode 100644 index 0000000000..afcb9a94f4 --- /dev/null +++ b/test/files/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"; + +} |