diff options
Diffstat (limited to 'tests/pos/implicits1.scala')
-rw-r--r-- | tests/pos/implicits1.scala | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/pos/implicits1.scala b/tests/pos/implicits1.scala index 4eae69325..2f0399b74 100644 --- a/tests/pos/implicits1.scala +++ b/tests/pos/implicits1.scala @@ -1,4 +1,6 @@ -class X(elem: Int) extends Object +class X(val elem: Int) { + def foo(y: String): Int = y.length + elem +} object Implicits { @@ -6,6 +8,12 @@ object Implicits { implicit def conv(x: Int): X = new X(x) + class Xdecorator(x: X) extends Object { + def foo(cond: Boolean): Int = if (cond) x.foo("abc") else 0 + } + + implicit def XDecorator(x: X) = new Xdecorator(x) + val a: Object = "abc" val b: Any = "abc" @@ -18,4 +26,10 @@ object Implicits { val z: X = 3 + val c: Int = y.elem + + val d: Int = z.foo("abc") + + // val e: Int = z.foo(true) not yet + } |