scalac doesn't find the right insert method in org.squeryl.Table

94 views Asked by At

I am trying to write a class that does generic inserts and updates of any entity type with Squeryl, following certain rules.

I have it compiling when it just calls update on a Table[E], but when I call insert on that same Table[E], with the same argument, the compiler complains that I'm passing in a T, not a org.squeryl.Query[T].

But there is a method in org.squeryl.Table called insert that takes a T as an argument!

It's not even an inherited method. It's right there in org.squeryl.Table!

It doesn't have any constraints or other implicit arguments.

How could scalac get something so simple so wrong?

I thought Eclipse might have been confused, but I get exactly the same result from building the project in sbt.

1

There are 1 answers

0
Robin Green On BEST ANSWER

This appears to have been caused by scalac narrowing the set of methods I could be calling based on the inferred return type. I needed to write the next line, which returns a value from the method (this was inside an if...else).

This is really unintuitive behaviour in the context of an IDE, in which the code is typechecked as soon as you type it. Instead of writing the next line, I was focusing on trying to fix the type error - which was merely a transient problem.