summaryrefslogtreecommitdiff
path: root/test/files/run/implicits.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2009-09-10 15:39:11 +0000
committerMartin Odersky <odersky@gmail.com>2009-09-10 15:39:11 +0000
commite72f0c7f2ff54f2afff3b612e7e9f9572ce3c82f (patch)
treed6f07e52e994609c8fc81624a987cc92a66b49b4 /test/files/run/implicits.scala
parent5f5b82e792094d3d51985167f96742f4ea210a31 (diff)
downloadscala-e72f0c7f2ff54f2afff3b612e7e9f9572ce3c82f.tar.gz
scala-e72f0c7f2ff54f2afff3b612e7e9f9572ce3c82f.tar.bz2
scala-e72f0c7f2ff54f2afff3b612e7e9f9572ce3c82f.zip
Massive redesign so that: scala> "hi" == "hi".r...
Massive redesign so that: scala> "hi" == "hi".reverse.reverse gives: res0: Boolean = true Preparing to do similar things to arrays.
Diffstat (limited to 'test/files/run/implicits.scala')
-rw-r--r--test/files/run/implicits.scala23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/files/run/implicits.scala b/test/files/run/implicits.scala
index 3fd3561fe7..e554575284 100644
--- a/test/files/run/implicits.scala
+++ b/test/files/run/implicits.scala
@@ -23,3 +23,26 @@ object Test extends Application {
Console.println(s)
Console.println(2: String)
}
+
+object TestPriority {
+
+ class C(x: Int) { def foo: Int = x + 1 }
+
+ class D(x: Int) { def foo: Int = x + 2 }
+
+ class IMPL {
+ implicit def Int2C(x: Int): C = new C(x)
+ }
+
+ object impl extends IMPL {
+ implicit def Int2D(x: Int): D = new D(x)
+ }
+
+ import impl._
+
+ val x: C = 2
+ val y: D = 2
+ assert(x.foo == 3, x.foo)
+ assert(y.foo == 4, y.foo)
+ assert((2).foo == 4, (2).foo)
+}