4

次のシナリオがあります。

case class B(v: String)
case class A(bs: Seq[B])

extension(a: A)
  def doit() = a.bs.map(_.doit()) // here is the exception

extension(b: B)
  def doit() = println("OK: ${b.v}")

これにより、コンパイル時に次の例外が発生します。

value doit is not a member of B.
An extension method was tried, but could not be fully constructed:

    _$1

Scala 3の拡張メソッドの命名に制限はありますか?

ここのScastieの例を参照してください

4

1 に答える 1