If an array literal contains at least one element that is a nil literal and at least one other element that is of type T, the type checker will set the element type of the array to Optional<T>:
This also works in other situations, where the type checker tries to find a common supertype of multiple expressions:
However, this currently only seems to work if T is a nominal type. If T is any other kind of type, there's a type error:
There is no reason why this shouldn't work with other types as well.