diff options
Diffstat (limited to 'test/files')
-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))) + } +} |