Why does the type inferencer fail here?

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Why does the type inferencer fail here?

Aaron Harnly-2-2
Given this method, Scala can infer the type of arguments just fine:
def foo[R](x: String => R) = x("Hello")

For example, I can call

and get back 5 just fine.

However, if I wrap the argument in a Tuple1, type inference fails:
def foo[R](x: Tuple1[String => R]) = x._1("Hello")

And call again:

& Scala complains with: error:
missing parameter type for expanded function ((x$1) => x$1.length)

Can anyone shed light on why the second case can't be figured out,
but the first one can?