Scala type mismatch error involving generics and refined types The following is a simplified version of a type-mismatch error I’m trying to solve: