E178: Missing Argument List — 빠진 인자 목록

E178: Missing Argument List — 빠진 인자 목록

여러 파라미터 목록을 가진 메서드를 호출할 때 필요한 인자 목록을 모두 제공하지 않았을 때 발생하는 에러예요.

출처: Scala 3 Reference

본문

Scala에서 메서드는 여러 개의 파라미터 목록(커리된 메서드)을 가질 수 있어요. 이런 메서드를 호출할 때는 부분 적용된 메서드가 함수 타입으로 명시적으로 기대되지 않는 한, 모든 파라미터 목록을 제공해야 해요.

부분 적용(미적용)된 메서드는 함수 타입이 기대될 때만 함수로 변환돼요.

예시 (Example)

object Test:
  def multiParam()()(x: Int): Int = x
  multiParam()  // missing argument lists

에러 (Error)

-- [E178] Type Error: example.scala:3:12 ---------------------------------------
3 |  multiParam()  // missing argument lists
  |  ^^^^^^^^^^^^
  |  missing argument list for method multiParam in object Test
  |
  |    def multiParam()()(x: Int): Int
  |-----------------------------------------------------------------------------
  | Explanation (enabled by `-explain`)
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  | Unapplied methods are only converted to functions when a function type is expected.
   -----------------------------------------------------------------------------

해결 방법 (Solution)

필요한 모든 인자 목록을 제공해주세요:

object Test:
  def multiParam()()(x: Int): Int = x
  val result = multiParam()()(42)  // provide all argument lists

부분 적용을 의도했다면 명시적으로 함수로 변환하세요:

object Test:
  def multiParam()()(x: Int): Int = x
  val partialFn: Int => Int = multiParam()()  // explicit function type

더 알아보기

부분 적용을 원한다면 함수 타입을 명시하면 돼요. 아니면 원래 의도대로 모든 인자 목록을 다 채워주세요.