Only v2 compiles bellow. I'd like instead to be able to call my apply method as in the v1 example. The compiler seems to be too quick to assign Nothing to my R variable
(inferred type arguments [...A,Nothing] do not conform to method apply's type parameter bounds [T1 <: Nothing,T2 <: Nothing] val v1 = apply(3)(new A)(new B))
class C
class A extends C
class B extends C
object O {
def apply[T1 <: R, T2 <: R, R](d : Int)(succ : T1)(fail : T2): R = if (d<0) succ else fail
val v1 = apply(3)(new A)(new B)
val v2 = apply[A, B, C](3)(new A)(new B)
}
R. I'm not sure why you need any type parameters at all though, because nothing is truly constrained.Rcould always beAny, which doesn't do much good. - Michael ZajacR(SoRis supposed to be a sum type) - Cristian Martin