There is this post that discusses chaining of implicits but I think it doesn't cover my case because I have generic implicits. Sample project that demonstrates the issue is located here. To reproduce these two lines should be commented out.
So I have number of implicits vals for concrete types such as
implicit val ObjectIdColumnType: ColumnType[ObjectId] = MappedColumnType.base[ObjectId, Array[Byte]](
{ obj => obj.toByteArray }, { arr => new ObjectId(arr) }
)
I'd like all of them automagically produce GetResult[T]
implicit vals. Thus I wrote following function
implicit def getResultForTypedTypes[T](implicit bct: ColumnType[T]): GetResult[T] =
GetResult[T](r => bct.getValue(r.rs, r.currentPos))
and I expect that function with prototype such as
def << [T](implicit f: GetResult[T]): T = f(this)
would be able to pick up GetResult[ObjectId]
Sadly I get error
Error:(78, 20) could not find implicit value for parameter f: slick.jdbc.GetResult[org.bson.types.ObjectId]
val id = r.<<[ObjectId]
^
I enabled log-implicits and found that seemingly unrelated implicit gets in a way
Information:(78, 20) getResultForTypedTypes is not a valid implicit value for slick.jdbc.GetResult[org.bson.types.ObjectId] because:
hasMatchingSymbol reported error: ambiguous implicit values:
both value strListTypeMapper in object MyAPI of type => co.greenhouse.rabbit.server.db.MyPostgresDriver.DriverJdbcType[List[String]]
and value ObjectIdColumnType in object MyAPI of type => co.greenhouse.rabbit.server.db.MyPostgresDriver.BaseColumnType[org.bson.types.ObjectId]
match expected type co.greenhouse.rabbit.server.db.MyPostgresDriver.api.BaseColumnType[T]
val id = r.<<[ObjectId]
^
How can I find the issue in this spaghetti of implicits ?