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.