GROOVY-6042: Removed two explicit casts that may fail at runtime