Scala “中的反直觉建议”;缺少参数列表“-具有多个参数列表的方法的错误消息?

Scala “中的反直觉建议”;缺少参数列表“-具有多个参数列表的方法的错误消息?,scala,compiler-errors,Scala,Compiler Errors,考虑以下代码段: def foo(a: Int)(b: Int) = a + b foo 它不编译,并生成以下错误消息: error: missing argument list for method foo Unapplied methods are only converted to functions when a function type is expected. You can make this conversion explicit by writing `foo _`

考虑以下代码段:

def foo(a: Int)(b: Int) = a + b
foo
它不编译,并生成以下错误消息:

error: missing argument list for method foo
Unapplied methods are only converted to functions when 
  a function type is expected.
You can make this conversion explicit by writing 
`foo _` or `foo(_)(_)` instead of `foo`.
error: missing parameter type for expanded 
function ((x$1: <error>, x$2: <error>) => foo(x$1)(x$2))
foo
提示有效。但是如果我写这个表达式

foo(_)(_)
如前一条错误消息所示,我收到一条新的错误消息:

error: missing argument list for method foo
Unapplied methods are only converted to functions when 
  a function type is expected.
You can make this conversion explicit by writing 
`foo _` or `foo(_)(_)` instead of `foo`.
error: missing parameter type for expanded 
function ((x$1: <error>, x$2: <error>) => foo(x$1)(x$2))
错误:缺少扩展的参数类型
函数((x$1:,x$2:)=>foo(x$1)(x$2))
这似乎有点违反直觉

在什么情况下,
foo()()
-提示应该是有用的,它到底告诉了我什么

(噪音被消除了;我越是不断地编辑这个问题,它就越没有意义;科尔马是对的)

foo(41;(41;的类型是
(Int,Int)=>Int
。因此,如果指定该类型或在预期该类型的上下文中使用该类型,则它会起作用:

scala> foo(_: Int)(_: Int)
res1: (Int, Int) => Int = $$Lambda$1120/1321433666@798b36fd

scala> val f: (Int, Int) => Int = foo(_)(_)
f: (Int, Int) => Int = $$Lambda$1121/1281445260@2ae4c424

scala> def bar(f: (Int, Int) => Int): Int = f(10, 20)
bar: (f: (Int, Int) => Int)Int

scala> bar(foo(_)(_))
res2: Int = 30

是的,非常感谢。我想当我试图理解时,我真的设法通过一个毫无戒心的新手的眼睛看到了错误消息。