Hi Russ,
Haoyi's suggestion would work for you. Here's an implementation:
trait OverloadResolver[T] {
def apply(t: T, j: Int): T
}
object OverloadResolver {
implicit val intOverload = new OverloadResolver[Int] {
def apply(t: Int, j: Int) = t + j
}
implicit val stringOverload = new OverloadResolver[String] {
def apply(t: String, j: Int) = t
}
}
class Foo {
def bar[T](t: T, j: Int = 0)(implicit or: OverloadResolver[T]): T =
or(t, j)
}
As you can see, it's a lot of extra code for a relatively tiny difference...
Cheers,
Jon