Given member definitions starting with `with` are no longer supported

Given the following code (pun not intended):

trait Display[A]:
  def display(value: A): String


object Display:
  given stringDisplay: Display[String] with
    def display(input: String) = input

IntelliJ displays the following warning:

Given member definitions starting with with are no longer supported; use {...} or : followed by newline instead

This is odd because the official documentation still shows given...with, and I can’t find anything corresponding to this message online. I even looked in the change logs going back to version 3.2, and found nothing.

Furthermore, I don’t know how to apply the suggestion, because none of the following compiles:

given stringDisplay: Display[String] {
    def display(input: String) = input
}

given stringDisplay: Display[String]:
  def display(input: String) = input

What would be the correct syntax to apply the suggestion from IntelliJ? Using Scala 3.6.2.

After digging through Scala change logs and commits, I found commit 14acdc0 to support SIP-64, which changes context bound and given clause syntaxes.

The new syntax is to replace the with with a :, exactly as suggested by the message. However, IntelliJ CE 2024.3.1.1 doesn’t recognize this syntax, neither does scalameta. I’ve opened tickets for each.

scalameta: Parsing fails on SIP-64 changes · Issue #4090 · scalameta/scalameta · GitHub

IntelliJ: https://youtrack.jetbrains.com/issue/SCL-23372/Fails-to-recognize-SIP-64-syntax

Yes, this was changed in 3.6.

Also, I know there were already tickets for both and I think metals already supported it.

There is a thread for awareness of current limitations.