minor refactor (improve null handling case)
GROOVY-7162: Handle @Immutable in class hierarchy?