I see this error when trying to extend unorthodox 'types' like (Int, Int)
, or Any
:
Non-nominal type 'Any' cannot be extended
So what makes a type non-nominal? What's the difference between a non-nominal type like Any
or (Int)
and a regular nominal type like Int
?
This is somewhat of a guess (edit: it's wrong, look at Brent's answer), but here goes:
Any
is a protocol, not an actual type. The word "Nominal" implies naming (based on the root of the word).
So you can't extend Any
because it's a protocol, not an actual type, and you can't extend (Int, Int)
because that's just a tuple literal, again not an actual type that you could specify by name.
You can, of course, extend protocols. Any
is not a protocol, it's (shocker) a non-nominal type which is something else. Read Brent's answer; he did a good job.