コンパイラのバグのようです。この式をさまざまなバージョンの scala でテストし、次のことを確認しました。
def f(xs: List[Int]) = (0 /: xs) _
と の場合は同じように動作し2.9.1.final
ます2.8.2.final
が、2.7.7.final
異なるエラー メッセージ ( Iterable
vs. TraversableOnes
) が表示されますが、古いバージョンでのコレクション ライブラリの再設計が原因だと思います。
def f(xs: List[Int]) = (0 /: xs) _
<console>:4: error: missing arguments for method /: in trait Iterable;
follow this method with `_' if you want to treat it as a partially applied function
コメントで言及した式は、異なる scala バージョンでは異なる動作をします。
def f(xs: List[Int]): (Int, Int) => Int => Int = (0 /: xs)
スカラ 2.9.1.final:
found : (Int, Int) => Int => Int
required: (Int, Int) => Int => Int
本当に紛らわしいコンパイラ メッセージです。間違いなくバグです。
スカラ 2.8.2.final:
found : => ((Int, Int) => Int) => Int
required: (Int, Int) => (Int) => Int
最初は奇妙=>
ですが、2.7.7 と比較すると、最終結果は回帰のように見えます。
スカラ 2.7.7.final:
found : ((Int, Int) => Int) => Int
required: (Int, Int) => (Int) => Int
found
一見正しいように見えますが、コードはまだ機能していません。
scala bugtrackerで同様の問題を検索しましたが、適切なものが見つかりませんでした。チケットを作成するだけで十分だと思います (または 2 つ? この 2 つのエラーは関連していないようです)。