Error when forgetting to import a driver's implicits

58 views
Skip to first unread message

Bill Atkins

unread,
Jun 2, 2012, 12:11:41 PM6/2/12
to ScalaQuery
I'm running ScalaQuery 0.10.0-M1. If I neglect to import my driver's
implicits in my application, I get cryptic compile errors about all of
my queries:

value filter is not a member of Foo with models.db.BaseModel[_, _]
[error] val q = this.filter(_.id is rowid).map(_.isActive)

Importing the implicits fixes this. Can I propose that we annotate the
needed implicit object class with an @implicitNotFound to make this
easier to debug, e.g.:

@implicitNotFound(msg = "Cannot find implicits for your ScalaQuery
driver; try import org.scalaquery.ql.extended.DRIVER_NAME.Implicit._")

In my source tree, I think this would go on the
BasicImplicitConversions trait. Please disregard if this is already
done in master.

Stefan Zeiger

unread,
Jun 4, 2012, 9:25:47 AM6/4/12
to scala...@googlegroups.com
On 2012-06-02 18:11, Bill Atkins wrote:
I'm running ScalaQuery 0.10.0-M1. If I neglect to import my driver's
implicits in my application, I get cryptic compile errors about all of
my queries:

    value filter is not a member of Foo with models.db.BaseModel[_, _]
    [error]     val q = this.filter(_.id is rowid).map(_.isActive)

Importing the implicits fixes this. Can I propose that we annotate the
needed implicit object class with an @implicitNotFound to make this
easier to debug, e.g.:

That won't work. You're missing an implicit conversion that gives you the filter method. If you don't import that conversion, the compiler has no idea that it even exists. @implicitNotFound works only for implicit arguments where the compiler knows the type of the argument. It never knows the type when you're forcing an implicit conversion by a method call.

--
Stefan Zeiger
Typesafe - The software stack for applications that scale
Twitter: @StefanZeiger
Reply all
Reply to author
Forward
0 new messages