aboutsummaryrefslogtreecommitdiff
path: root/tests/pos/inferred.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-09-27 22:10:45 +0200
committerMartin Odersky <odersky@gmail.com>2013-09-28 11:43:43 +0200
commit0c582b883971fd89476244aa6905be95da7e79d0 (patch)
tree079efc09d1e5b53b1e258b565dbb15c8b14954f7 /tests/pos/inferred.scala
parentfcb68309c2760a6797b0a9ec23722808060e9aa1 (diff)
downloaddotty-0c582b883971fd89476244aa6905be95da7e79d0.tar.gz
dotty-0c582b883971fd89476244aa6905be95da7e79d0.tar.bz2
dotty-0c582b883971fd89476244aa6905be95da7e79d0.zip
Several bug fixes to typer and classfile reader.
In particular, changed internal representation of Java constructors and changed treatment of parent constructors in templates.
Diffstat (limited to 'tests/pos/inferred.scala')
-rw-r--r--tests/pos/inferred.scala24
1 files changed, 18 insertions, 6 deletions
diff --git a/tests/pos/inferred.scala b/tests/pos/inferred.scala
index 29e1345c1..432cd8acd 100644
--- a/tests/pos/inferred.scala
+++ b/tests/pos/inferred.scala
@@ -1,14 +1,26 @@
class List[+T] {
- def prepend [U >: T] (x: U): List[U] = null//new Cons(x, this)
+ def isEmpty: Boolean
+ def head: T
+ def tail: List[T]
- def map[U](f: T => U): List[U] = null
+ def prepend [U >: T] (x: U): List[U] = new Cons(x, this)
+
+ def map[U](f: T => U): List[U] = if (isEmpty) Nil else tail.map(f).prepend(f(head))
}
-object Nil extends List[Nothing]
+object Nil extends List[Nothing] {
+ def isEmpty = true
+ def head = throw new Error()
+ def tail = ???
+}
-//class Cons[T](hd: T, tl: List[T]) extends List[T]
+class Cons[T](hd: T, tl: List[T]) extends List[T] {
+ def isEmpty = false
+ def head = hd
+ def tail = tl
+}
object Inferred {
@@ -35,7 +47,7 @@ object Inferred {
val ss3 = "abc" :: n2
- def closure = ((x: Int) => x)
+ def cl = ((x: Int) => x + 1)
- val ints2 = ints map closure
+ val ints2 = ints map (_ + 1)
} \ No newline at end of file