scalatypesprojectionconcrete

Represent T* as concrete type


(T,T)* resolves to Seq[(T,T)] after erasure, but how to represent (T,T)* itself as a type?

The reason I ask is there's an API I'm using that defines a:

def foo(bar: (String,String)*) = ...

but fails when I try to pass in a Seq[(String,String)].

My pull request to add in:

def foo(bar: Seq[(String,String)]) = ...

blows up due to the 2 methods having the same type after erasure.

Are star projections able to be represented as a concrete type?


Solution

  • You can pass the Seq if you follow it with :_* like this:

    val s:Seq[(String, String)] = Seq( ("a", "b"), ("c", "d"), ... )
    foo(s:_*)
    

    So you shouldn't need both signatures.