The key aspect for that example is in the preceding paragraph "When
code is annotated with @TypeChecked".
If you had those three lines in a script called Upper.groovy, you could try:
> groovy --compile-static Upper.groovy
Or in the groovyConsole, you could try something like this:
Hi
In the example of the documentation
https://groovy-lang.org/semantics.html#type-inference the callout number
3 states 'calling |upper| will fail at compile time'. But when I run
those three lines of code in GroovyConsole I get
groovy.lang.MissingMethodException which is a runtime exception.