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/pos | |
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/pos')
-rw-r--r-- | test/files/pos/t0786.scala | 29 | ||||
-rw-r--r-- | test/files/pos/t0904.scala | 17 |
2 files changed, 46 insertions, 0 deletions
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. +} |