I read existing questions about how type definitions with parameterized bounds are illegal inside blocks (or something to that effect), but it doesn't help me in my problem:
type Cons[X]
class Higher[C[X] <: Cons[X]]
type AnyHigher = Higher[C] forSome { type C[X] <: Cons[X] }
Seq[AnyHigher]().map { h => h }
compiler:
can't existentially abstract over parameterized type C
Seq[AnyHigher]().map { h => h }
The element type of the input collection is irrelevant, the problem lies only in the return type of the mapping function. Is there any way around this? I tried various refactors: making the mapping function a method, cheating by making the code generic and executing parameterized with AnyHigher
, writing my own recursion, but nothing helps.