Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Information Provided
-
2.3.7
-
None
-
None
Description
def someCollection = null someCollection.collect { e -> e.name } // returns [] someCollection*.name // returns null (or [] for SC) someCollection.name // throws NullPointerException
Actual:
someCollection is null, with no typing hints as to what someCollection really is, and yet it invokes .collect() on a null reference. How is that possible without collect being a global function?
Expected:
All 3 situations throw a NPE. The spread operator seems to short circuit nulls like the ?. operator. So really the spread operator is more like ?.* operator which is maybe desirable. But it's not explicit that it does that and is a bit surprising given we have the difference of . and ?. At the least this is inconsistent between these various operations.