summaryrefslogtreecommitdiff
path: root/test/files/neg/t6260.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2012-09-10 18:07:20 +0200
committerPaul Phillips <paulp@improving.org>2012-09-20 09:41:33 -0700
commit96408154f46dce623d3b3c3fdc67f5ccc3779f8f (patch)
treecc02888f504bf1ebbd131d0297145b31684222f5 /test/files/neg/t6260.scala
parentd834d90d88e1dab6a8621b13c9d4b64d3417a94e (diff)
downloadscala-96408154f46dce623d3b3c3fdc67f5ccc3779f8f.tar.gz
scala-96408154f46dce623d3b3c3fdc67f5ccc3779f8f.tar.bz2
scala-96408154f46dce623d3b3c3fdc67f5ccc3779f8f.zip
Fixes SI-6260
Guards against bridge methods that clash with other methods. Two tests: The neg test is the original ticket. The run test tweaks things slightly so that the generated bridge method does not clash, and tests that the necessary unboxings are indeed performed at runtime.
Diffstat (limited to 'test/files/neg/t6260.scala')
-rw-r--r--test/files/neg/t6260.scala17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/files/neg/t6260.scala b/test/files/neg/t6260.scala
new file mode 100644
index 0000000000..93b5448227
--- /dev/null
+++ b/test/files/neg/t6260.scala
@@ -0,0 +1,17 @@
+class Box[X](val x: X) extends AnyVal {
+ def map[Y](f: X => Y): Box[Y] =
+ ((bx: Box[X]) => new Box(f(bx.x)))(this)
+}
+
+object Test {
+ def map2[X, Y](self: Box[X], f: X => Y): Box[Y] =
+ ((bx: Box[X]) => new Box(f(bx.x)))(self)
+
+ def main(args: Array[String]) {
+ val f = (x: Int) => x + 1
+ val g = (x: String) => x + x
+
+ map2(new Box(42), f)
+ new Box("abc") map g
+ }
+}