Checking Toolchain in cpp-library - example in docs doesn't work

https://docs.gradle.org/current/userguide/building_cpp_projects.html

Has an example for adding compiler options:

tasks.withType(CppCompile).configureEach {
    // Define a preprocessor macro for every binary
    macros.put("NDEBUG", null)

    // Define a compiler options
    compilerArgs.add '-W3'

    // Define toolchain-specific compiler options
    compilerArgs.addAll toolChain.map { toolChain ->
        if (toolChain in [ Gcc, Clang ]) {
            return ['-O2', '-fno-access-control']
        } else if (toolChain in VisualCpp) {
            return ['/Zi']
        }
        return []
    }
}

However with Gradle 7.2 the line: if (toolChain in [ Gcc, Clang ]) { does not match for me. I had to change this to: if (toolChain in Gcc || toolChain in Clang) {

Is this a bug in the docs or in Gradle?