What version of scala are you using?
--
I'm only updating the book to Lift 2.0 at this point, so Scala 2.7.7.
Right, sorry, that's what I meant. NodeSeq extends Seq[Node], so it would also match listElemToResponse.
Why isimplicit def nodeSeqToFoo(in: Seq[Node]): Foo = ...not sufficient for both?
On Fri, Oct 8, 2010 at 9:50 PM, Naftoli Gugenheim <nafto...@gmail.com> wrote:Why isimplicit def nodeSeqToFoo(in: Seq[Node]): Foo = ...not sufficient for both?As I said in my prior message: "Why? Because 2.7.7 does not look at the type parameter of the superclass when it's looking for implicits."
I'm returning an item of type Elem, which extends Node. Node extends NodeSeq, which matches the nodeSeqToResponse implicit, but NodeSeq also extends Seq[Node], which matches the listElemToResponse implicit. So it seems like, at least in 2.7.7, the conversions are checked all the way up the type hierarchy.
It seems that since Seq[Node] is the topmost class in the hierarchy that listElemToResponse should cover both NodeSeq and Seq[Node]. I'll go ahead and make a test branch and test the conversions as you stated to make sure that things still work if nodeSeqToResponse is gone.
OK, I'm almost done coding this up and things look good. One thing I noticed, though, is that the canNodeToResponse implicit takes a NodeSeq while listElemToResponse takes a Seq[Node]. If Scala is doing implicit checks the way we think it is, it shouldn't be a breaking change to broaden canNodeToResponse to take a Seq[Node], but I want to check to make sure that's OK before I slip that in.