Does Gradle support Groovy switch expressions?

This code does not compile with Gradle 7.6.3:

def x = switch (true) {
    case true -> "hello"
    case false -> "hi"
}
Unexpected input: 'switch' @ line 81, column 9.
     def x = switch (true) {
             ^

but it’s perfectly valid Groovy code according to the docs: The Apache Groovy programming language - Semantics

Forget it - switch expressions were added in Groovy 4.0, Gradle uses 3.x.

I would expect IDEA to highlight this as a syntax error but it does not… hence the confusion.