E102: Undefined Named Type Parameter

E102: Undefined Named Type Parameter (정의되지 않은 이름 붙은 타입 파라미터)

이름 붙은 타입 인자가 정의에 존재하지 않는 타입 파라미터를 가리킬 때 나오는 에러예요.

출처: Scala 3 Reference

본문

이름 붙은 타입 인자를 사용할 때는 메서드나 클래스 정의에 선언된 타입 파라미터의 이름을 정확히 그대로 써야 해요.

예시

import scala.language.experimental.namedTypeArguments

def example[A, B](a: A, b: B): (A, B) = (a, b)

val result = example[A = Int, C = String](1, "hello")

에러 메시지

-- [E102] Syntax Error: example.scala:5:34 -------------------------------------
5 |val result = example[A = Int, C = String](1, "hello")
  |                                  ^^^^^^
  |                      Type parameter C is undefined. Expected one of A, B.

해결 방법

실제로 존재하는 올바른 타입 파라미터 이름을 사용해요.

// Use the correct, existing, type parameter name
import scala.language.experimental.namedTypeArguments

def example[A, B](a: A, b: B): (A, B) = (a, b)

val result = example[A = Int, B = String](1, "hello")