aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-08-27 14:12:31 +0200
committerMartin Odersky <odersky@gmail.com>2013-08-27 14:12:41 +0200
commite2a05a5ac38647f9727d1e0ec8c3c14ac82b5de7 (patch)
tree78b7e72faf3fd4478c82048c4f65f2528684525e /tests
parenteab2123cd727fad2e0139e63edacfff7307d49f0 (diff)
downloaddotty-e2a05a5ac38647f9727d1e0ec8c3c14ac82b5de7.tar.gz
dotty-e2a05a5ac38647f9727d1e0ec8c3c14ac82b5de7.tar.bz2
dotty-e2a05a5ac38647f9727d1e0ec8c3c14ac82b5de7.zip
Fixed bugs related to typechecking closures.
Diffstat (limited to 'tests')
-rw-r--r--tests/pos/functions1.scala13
-rw-r--r--tests/pos/implicits1.scala16
2 files changed, 28 insertions, 1 deletions
diff --git a/tests/pos/functions1.scala b/tests/pos/functions1.scala
new file mode 100644
index 000000000..72686ca15
--- /dev/null
+++ b/tests/pos/functions1.scala
@@ -0,0 +1,13 @@
+class X(val elem: Int) extends Object {
+ def foo(y: String): Int = y.length + elem
+}
+
+object Functions {
+
+ val x = new X(2)
+ val xe = x.elem
+ val xf: String => Int = x.foo(_)
+ val x2: String => Int = x.foo
+ val x3 = x.foo _
+
+}
diff --git a/tests/pos/implicits1.scala b/tests/pos/implicits1.scala
index 4eae69325..2f0399b74 100644
--- a/tests/pos/implicits1.scala
+++ b/tests/pos/implicits1.scala
@@ -1,4 +1,6 @@
-class X(elem: Int) extends Object
+class X(val elem: Int) {
+ def foo(y: String): Int = y.length + elem
+}
object Implicits {
@@ -6,6 +8,12 @@ object Implicits {
implicit def conv(x: Int): X = new X(x)
+ class Xdecorator(x: X) extends Object {
+ def foo(cond: Boolean): Int = if (cond) x.foo("abc") else 0
+ }
+
+ implicit def XDecorator(x: X) = new Xdecorator(x)
+
val a: Object = "abc"
val b: Any = "abc"
@@ -18,4 +26,10 @@ object Implicits {
val z: X = 3
+ val c: Int = y.elem
+
+ val d: Int = z.foo("abc")
+
+ // val e: Int = z.foo(true) not yet
+
}