scala/scala3

Unhelpful "This old given syntax is no longer supported" warning

Opened this issue · 2 comments

Compiler version

3.6.4

Minimized example

sealed trait IsVal[A]:
  type V
  def cons(v: V): A
  def decons(a: A): V

abstract class Get[A]:
  def map[B](f: A => B): Get[B]

object Mappings:
  given [A](using wrapped: IsVal[A], get: Get[wrapped.V]): Get[A] = get.map(wrapped.cons)

Output Error/Warning message

This old given syntax is no longer supported; use `=>` instead of `:`
  given [A](using wrapped: IsVal[A], get: Get[wrapped.V]): Get[A] = get.map(wrapped.cons)

Why this Error/Warning was not helpful

The message was unhelpful because it does not show how to use the new syntax (or if it is possible at all).

Hi!

I'm taking this message and trying to switch to new syntax.. How to add a using in this case?

// Old sintax

given OptionValidator[A: Validator](using
      msg: ValidatorMessages
  ): FieldValidator[Option[A]] =
    new FieldValidator[Option[A]]:
      def validate(
          fieldName: String,
          validations: Seq[validation],
          value: Option[A]
      ): Either[Seq[String], Unit] = Right(())

// New sintax, where do i put the using?

given OptionValidator: [A: Validator] => FieldValidator[Option[A]]:
      def validate(
          fieldName: String,
          validations: Seq[validation],
          value: Option[A]
      ): Either[Seq[String], Unit] = Right(())

Looks like I figured it out, is that it?

  given OptionValidator: [A: Validator] => (msg: ValidatorMessages) => FieldValidator[Option[A]]:
      def validate(
          fieldName: String,
          validations: Seq[validation],
          value: Option[A]
      ): Either[Seq[String], Unit] = Right(())