GROOVY-6051: Fix NPE in generics return type inference