Possible Duplicate:
How can I chain implicits in Scala?
Can Scala apply multiple implicit conversions in one expression?
Consider this simple example:
case class Wrapper(s: String)
case class WrapperWrapper(w: Wrapper)
implicit def string2Wrapper(s: String) = Wrapper(s)
implicit def wrapper2WrapperWrapper(w: Wrapper) = WrapperWrapper(w)
// implicit conversation --> w = string2Wrapper("w")
val w: Wrapper = "w"
// implicit conversation --> ww = wrapper2WrapperWrapper(w)
val ww: WrapperWrapper = w
// does NOT compile!
// ideally --> sad = wrapper2WrapperWrapper(string2Wrapper("ww"))
val sad: WrapperWrapper = "ww"
Is there any way to get the "double" conversion in the last line to work?
I can help things along by defining another implicit like:
implicit def string2WrapperWrapper(s:String) = wrapper2WrapperWrapper(s)
but it seems like that shouldn't be necessary...