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.