diff options
author | Martin Odersky <odersky@gmail.com> | 2008-05-21 17:32:29 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2008-05-21 17:32:29 +0000 |
commit | 96b80791737efd952383aba56ba69440e861647d (patch) | |
tree | 6df772e7a2d73ef0f934a18733486e06447d96c9 /test/files | |
parent | b7efa99768e14c03df810b129f979ba61aba8e87 (diff) | |
download | scala-96b80791737efd952383aba56ba69440e861647d.tar.gz scala-96b80791737efd952383aba56ba69440e861647d.tar.bz2 scala-96b80791737efd952383aba56ba69440e861647d.zip |
added tests; fixed #903; made Predef.Map covari...
added tests; fixed #903; made Predef.Map covariant in second parameter.
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/neg/t0903.check | 7 | ||||
-rw-r--r-- | test/files/neg/t0903.scala | 5 | ||||
-rw-r--r-- | test/files/pos/t0786.scala | 29 | ||||
-rw-r--r-- | test/files/pos/t0904.scala | 17 | ||||
-rw-r--r-- | test/files/run/t0677.scala | 6 |
5 files changed, 64 insertions, 0 deletions
diff --git a/test/files/neg/t0903.check b/test/files/neg/t0903.check new file mode 100644 index 0000000000..db4cd94d2c --- /dev/null +++ b/test/files/neg/t0903.check @@ -0,0 +1,7 @@ +t0903.scala:3: error: reassignment to val + x += 1 + ^ +t0903.scala:4: error: reassignment to val + x = 2 + ^ +two errors found diff --git a/test/files/neg/t0903.scala b/test/files/neg/t0903.scala new file mode 100644 index 0000000000..cf8abce97a --- /dev/null +++ b/test/files/neg/t0903.scala @@ -0,0 +1,5 @@ +object Test { + val x = 1 + x += 1 + x = 2 +} diff --git a/test/files/pos/t0786.scala b/test/files/pos/t0786.scala new file mode 100644 index 0000000000..d23cdb741b --- /dev/null +++ b/test/files/pos/t0786.scala @@ -0,0 +1,29 @@ +object ImplicitProblem { + class M[T] + + def nullval[T] = null.asInstanceOf[T]; + + trait Rep[T] { + def eval: int + } + + implicit def toRep0(n: int) = new Rep[int] { + def eval = 0 + } + + implicit def toRepN[T](n: M[T])(implicit f: T => Rep[T]) = new Rep[M[T]] { + def eval = f(nullval[T]).eval + 1 + } + + def depth[T <% Rep[T]](n: T) = n.eval + + def main(args: Array[String]) { + println(depth(nullval[M[int]])) // (1) this works + println(nullval[M[int]].eval) // (2) this works + + type m = M[int] + println(depth(nullval[m])) // (3) this doesn't compile on 2.7.RC1 + println(nullval[m].eval) // (4) this works + } + +} diff --git a/test/files/pos/t0904.scala b/test/files/pos/t0904.scala new file mode 100644 index 0000000000..28ad30fc2d --- /dev/null +++ b/test/files/pos/t0904.scala @@ -0,0 +1,17 @@ +trait A { + def apply(x: Int): Int + def update(x: Int, y: Int): Unit +} + +trait B extends A + +abstract class Foo { + val a: A = null + val b: B = null + + a(0) = 1 + b(0) = 1 + + a(0) += 1 + b(0) += 1 // this one does not type check. +} diff --git a/test/files/run/t0677.scala b/test/files/run/t0677.scala new file mode 100644 index 0000000000..7978e3d142 --- /dev/null +++ b/test/files/run/t0677.scala @@ -0,0 +1,6 @@ +object Test extends Application { + class X[T] { val a = new Array[Array[T]](3,4) } + val x = new X[String] + x.a(1)(2) = "hello" + assert(x.a(1)(2) == "hello") +} |