summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-11-17 04:51:43 +0000
committerPaul Phillips <paulp@improving.org>2009-11-17 04:51:43 +0000
commitdb99de350f3e1d2e2465d5bcd386b938fd7b2569 (patch)
tree97a5757229daa78ca9dfbfdecfb7f552ed5197d6 /test/files
parent60e6a45de9e713d007cea6af3b71605d5d08e06b (diff)
downloadscala-db99de350f3e1d2e2465d5bcd386b938fd7b2569.tar.gz
scala-db99de350f3e1d2e2465d5bcd386b938fd7b2569.tar.bz2
scala-db99de350f3e1d2e2465d5bcd386b938fd7b2569.zip
Fix and test case for #2636.
Diffstat (limited to 'test/files')
-rw-r--r--test/files/run/bug2636.scala35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/files/run/bug2636.scala b/test/files/run/bug2636.scala
new file mode 100644
index 0000000000..8c49a733fd
--- /dev/null
+++ b/test/files/run/bug2636.scala
@@ -0,0 +1,35 @@
+object Test
+{
+ type Foo = { def update(x: Int, value: String): Unit }
+ type Foo2 = { def update(x: Int, value: String): Int }
+ type Foo3 = { def update(x: Int, value: String): Array[Int] }
+
+ def alen() = {
+ type L1 = { def length: Int }
+ def len(p: L1) = p.length
+ val x: L1 = Array(1,2,3)
+ len(x)
+ }
+
+ type A1 = { def apply(x: Int): String }
+ def arrApply(a: A1, x: Int) = a(x)
+
+ def main(args: Array[String]): Unit = {
+ val arr = new Array[String](3)
+ val p1: Foo = arr
+ def a1 = p1(0) = "b"
+
+ val p2: Foo2 = new { def update(x: Int, value: String) = { p1(1) = "o" ; 1 } }
+ def a2 = p2(0) = "c"
+
+ val p3: Foo3 = new { def update(x: Int, value: String) = { p1(2) = "b" ; Array(1) } }
+ def a3 = p3(10) = "hi mom"
+
+ a1 ; a2 ; a3 ;
+
+ assert(arr.mkString == "bob")
+ assert(alen() == 3)
+ assert(arrApply(arr, 1) == "o")
+ assert(arrApply(new { def apply(x: Int) = "tom" }, -100) == "tom")
+ }
+} \ No newline at end of file