{ case X(x) => ... }
is a partial function, but the compiler still doesn’t know what your input type is, except that it’s a supertype of X
. Normally this isn’t a problem because if you’re writing an anonymous function, the type is known from the context. But here is how you can provide the type:
case class Foo(x: Int)
// via annotation
val f: Foo => Int = { case Foo(x) => x }
// use pattern matching
val f = (_: Foo) match { case Foo(x) => x }
// or more normally, write as a method
def f(a: Foo) = a match { case Foo(x) => x }
def f(a: Foo) = a.x
As you’ve probably noticed, using function literals / pattern matching here is pretty pointless. It seems in your case you just need a regular method:
def whatever(qt: QualifiedType) = {
t.ty = qt.ty
Some((emptyEqualityConstraintSet, qt.preds))
}
although you should refactor to remove that mutable state.