blob: 3f47259849d334b9e942c4d97bc651f61478bbe4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
object Test {
class Op[I];
class IntOp extends Op[Int];
class Rich(x : Double) {
def + (op : IntOp) = op;
def + [I](op : Op[I]) = op;
def plus [I](op : Op[I]) = op;
}
implicit def iToRich(x : Double) =
new Rich(x);
// fails to compile
val failure = 1.0 + new Op[Int];
// works as expected --
// problem isn't in adding new "+"
val a = 1.0 + new IntOp;
// works as expected --
// problem isn't in binding type variable I
val b = 1.0 plus new Op[Int];
// works as expected --
// problem isn't in using Rich.+[I](op : Op[I])
val c = iToRich(1.0) + new Op[Int];
}
|