diff options
Diffstat (limited to 'test/files')
-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 | ||||
-rw-r--r-- | test/files/pos/S1.scala | 13 | ||||
-rw-r--r-- | test/files/pos/S3.scala | 14 | ||||
-rw-r--r-- | test/files/pos/S5.scala | 30 | ||||
-rw-r--r-- | test/files/pos/S8.scala | 19 | ||||
-rw-r--r-- | test/files/pos/philippe3.scala | 40 | ||||
-rw-r--r-- | test/files/pos/scall.bat | 50 |
12 files changed, 253 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"; + +} diff --git a/test/files/pos/S1.scala b/test/files/pos/S1.scala new file mode 100644 index 0000000000..eba81109b3 --- /dev/null +++ b/test/files/pos/S1.scala @@ -0,0 +1,13 @@ +/* This is probably no bug, I just don't understand why +** type inference does not find the right instantiation of foo. +** Currently it reports: +** +** S1.scala:12: inferred type arguments [S1] do not conform to +** method foo's type parameter bounds [T <: S1.this.type] +** foo(this); +** ^ +*/ +class S1() { + def foo[T <: this.type](x: T) = x; + foo(this); +} diff --git a/test/files/pos/S3.scala b/test/files/pos/S3.scala new file mode 100644 index 0000000000..1e0f0288b1 --- /dev/null +++ b/test/files/pos/S3.scala @@ -0,0 +1,14 @@ +/* Why does this code fail? b has type a.type, so the third +** declaration in S3 should be okay... The compiler writes instead: +** +** found : S3.this.b.type (with underlying type S3) +** required: S3.this.a.type +** val c: a.type = b; +** ^ +** Without declaration 3, everything is fine. +*/ +class S3() { + val a = new S3(); + val b: a.type = a; + val c: a.type = b; +} diff --git a/test/files/pos/S5.scala b/test/files/pos/S5.scala new file mode 100644 index 0000000000..87325b47e4 --- /dev/null +++ b/test/files/pos/S5.scala @@ -0,0 +1,30 @@ +/* Here's a fragment of a Scala encoding for the Keris module system; +** the compiler claims: +** +** S5.scala:28: value n in class N of type N.this._N.n +** cannot override value n in class M of type M.this._N.n +** val system = new M() with N() {} +** ^ +** To me it seems like the code is perfectly fine... +*/ +abstract class M() { + val _N: N; + val n: _N.n; + val _M: M = this; + val m: _M.m = new _M.m(); + class m() { + // module body of M + } +} +abstract class N() { + val _N: N = this; + val n: _N.n = new _N.n(); + val _M: M; + val m: _M.m; + class n() { + // module body of N + } +} +module O { + val system = new M() with N() {} +} diff --git a/test/files/pos/S8.scala b/test/files/pos/S8.scala new file mode 100644 index 0000000000..e4339bb3f1 --- /dev/null +++ b/test/files/pos/S8.scala @@ -0,0 +1,19 @@ +/* I believe this code is correct, but the compiler rejects it: +** +** S8.scala:18: type mismatch; +** found : M.x.A +** required: M.x.a.B +** val y: x.a.B = new x.A(); //correct? +** ^ +** For a given value x of type S8, type x.A should be +** a subtype of x.a.B. +*/ +class S8() { + val a: S8 = this; + class A() extends a.B() {} + class B() {} +} +module M { + val x = new S8(); + val y: x.a.B = new x.A(); //correct? +} diff --git a/test/files/pos/philippe3.scala b/test/files/pos/philippe3.scala new file mode 100644 index 0000000000..d99ec41f52 --- /dev/null +++ b/test/files/pos/philippe3.scala @@ -0,0 +1,40 @@ + +class Foo(x: Int) {} +case class Bar(y: Int) extends Foo(y); + + +trait T {} +trait U {} +class C() {} + + +trait T1; +trait T2 {} +trait T5 extends T; +trait T6 extends T {} +trait T7 extends T with U; +trait T8 extends T with U {} + +class C1(); +class C2() {} +class C5() extends C(); +class C6() extends C() {} +class C7() extends C() with U; +class C8() extends C() with U {} + +case class D1(); +case class D2() {} +case class D5() extends C(); +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 {} + + + diff --git a/test/files/pos/scall.bat b/test/files/pos/scall.bat new file mode 100644 index 0000000000..4e9f31425e --- /dev/null +++ b/test/files/pos/scall.bat @@ -0,0 +1,50 @@ +scalac -prompt A.scala; +scalac -prompt IntSet.scala; +scalac -prompt List1.scala; +scalac -prompt Rational.scala; +scalac -prompt X.scala; +scalac -prompt Y.scala; +scalac -prompt Z.scala; +scalac -prompt abstract.scala; +scalac -prompt cls.scala; +scalac -prompt cls1.scala; +scalac -prompt clsrefine.scala; +scalac -prompt cours1.scala; +scalac -prompt cours2.scala; +scalac -prompt cours2a.scala; +scalac -prompt cours2b.scala; +scalac -prompt cours2c.scala; +scalac -prompt eta.scala; +scalac -prompt exceptions.scala; +scalac -prompt imports.scala; +scalac -prompt lambda.scala; +scalac -prompt lambdalift.scala; +scalac -prompt lambdalift1.scala; +scalac -prompt matthias1.scala; +scalac -prompt maxim1.scala; +scalac -prompt michel1.scala; +scalac -prompt michel2.scala; +scalac -prompt michel3.scala; +scalac -prompt michel4.scala; +scalac -prompt michel5.scala; +scalac -prompt modules.scala; +scalac -prompt modules1.scala; +scalac -prompt moduletrans.scala; +scalac -prompt nested.scala; +scalac -prompt override.scala; +scalac -prompt patterns.scala; +scalac -prompt patterns2.scala; +scalac -prompt philippe1.scala; +scalac -prompt philippe2.scala; +scalac -prompt reftest.scala; +scalac -prompt sort1.scala; +scalac -prompt sqrt.scala; +scalac -prompt stable.scala; +scalac -prompt strings.scala; +scalac -prompt test1.scala; +scalac -prompt test2.scala; +scalac -prompt test4.scala; +scalac -prompt test4a.scala; +scalac -prompt test4refine.scala; +scalac -prompt test5.scala; +scalac -prompt test5refine.scala; |