diff options
author | Paul Phillips <paulp@improving.org> | 2010-03-20 04:24:39 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-03-20 04:24:39 +0000 |
commit | a4f00eaf4da004ee2fd8a1ac1135b465533415d4 (patch) | |
tree | 6bd5d70be6c2e7bcf2c2ef07514c67f4d45b4757 /test | |
parent | 44fddf75406a83017791677b53126fe9a6d6a17b (diff) | |
download | scala-a4f00eaf4da004ee2fd8a1ac1135b465533415d4.tar.gz scala-a4f00eaf4da004ee2fd8a1ac1135b465533415d4.tar.bz2 scala-a4f00eaf4da004ee2fd8a1ac1135b465533415d4.zip |
Some work on the Array methods as they manifest...
Some work on the Array methods as they manifest in refinement types:
tightening when Array code is generated and also what code is generated.
Review by dubochet.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/bug3175.check | 8 | ||||
-rw-r--r-- | test/files/run/bug3175.scala | 44 |
2 files changed, 52 insertions, 0 deletions
diff --git a/test/files/run/bug3175.check b/test/files/run/bug3175.check new file mode 100644 index 0000000000..daf2c23ab5 --- /dev/null +++ b/test/files/run/bug3175.check @@ -0,0 +1,8 @@ +10 +15 +3 +3 +3 +5 +5 +5 diff --git a/test/files/run/bug3175.scala b/test/files/run/bug3175.scala new file mode 100644 index 0000000000..9cccff52f9 --- /dev/null +++ b/test/files/run/bug3175.scala @@ -0,0 +1,44 @@ +/** A bit down the road this test will examine + * the bytecode. + */ +object Test { + def len(x:{ def length: Int }) = x.length + def f1(x:{ def apply(x: Int): Long }) = x(0) + def f2(x:{ def apply(x: Int): Byte }) = x(0) + def f3(x:{ def apply(x: Int): String }) = x(0).length + + def f4(x:{ def update(x: Int, y: Long): Unit }, y: Long) = x(0) = y + def f5(x:{ def update(x: Int, y: Byte): Unit }, y: Byte) = x(0) = y + def f6(x:{ def update(x: Int, y: String): Unit }, y: String) = x(0) = y + + def f7(x: { def length: Any }) = x.length + + def f8(x: { def apply(x: Int): Any }) = x(0) + def f9(x: { def apply(x: Int): Int }) = x(0) + def f10(x: { def apply(x: Int): Long }) = x(0) + + // doesn't work yet, see #3197 + // def fclone(x:{ def clone(): AnyRef }) = x.clone() + + def main(args: Array[String]): Unit = { + val longs = Array(5L) + val bytes = Array(5: Byte) + val strs = Array("abcde", "fghjij") + + println(len(Array(1,2,3)) + len(Array(4.0,5.0f)) + len(Array("abc", 5)) + len("bop")) + println(f1(longs) + f2(bytes) + f3(strs)) + + f4(longs, 1) + f5(bytes, 1) + f6(strs, "a") + + println(f1(longs) + f2(bytes) + f3(strs)) + + println(f7(Array(1,2,3))) + println(f7("def")) + + println(f8(Array(5))) + println(f9(Array(5))) + println(f10(Array(5))) + } +} |