Some of the conditions for a shared function of type T: T1 -> T2
to be a subtype of another shared function U: U1 -> U2
are said to be:
U1 <: T1
T2 <: U2
This means that:
- The arguments of
T
must be a supertype of the arguments ofU
- The return type of
T
must be a subtype of the return type ofU
But when testing in Motoko Playground and DFX only the reverse condition allows upgrading without a backwards compatibility warning:
T1 <: U1
U2 <: T2
This last condition, where arguments can ‘grow’ in type and return types can only ‘shrink’ in type, is the one that makes most sense to clients and implementers of functions.