Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tuple inference fails

Hi so I have a trait with generics +T and +U.

def test[I >: T, V >: U](e: Traversable[I], f: V)
def test[I >: T, V >: U](e: (Traversable[I], V))
def test[I >: T, V >: U](e: Tuple2[Traversable[I], V])

The first one works fine. The last 2 however both spit out:

type mismatch;
[error]  found   : (String, Int)
[error]  required: (Traversable[?], ?)

Why can scala not infer the types in the 2nd and 3rd examples? What am I missing?

Thanks

like image 563
Vangogh500 Avatar asked Aug 18 '26 13:08

Vangogh500


1 Answers

This looks like a compiler bug to me. I don't see a reason why it can convert String to Traversable in the first case but not the other two cases.

like image 71
Ziyang Liu Avatar answered Aug 21 '26 09:08

Ziyang Liu