Is it possible to generalize the return types of a Map of functions with variable return types to a common signature and then use the actual return type of each function in the Map at runtime?
I'm having a scala Map of string -> functions defined as:
Map[String, (String) => Seq[Any]] = Map("1" -> foo, 2 -> bar, 3 -> baz)
where foo, bar and baz are defined as:
foo(string: String): Seq[A] bar(string: String): Seq[B] baz(string: String): Seq[C]
The compilation works fine but at runtime Seq[A or B or C] types returned by the functions are being treated as Seq[Any] thereby giving me a reflection exception.