With version 0.9.0 users are able to define generics in their contracts and interfaces.
Although contracts generics can be set as any concrete types by users importing these contracts to their own it is impossible to forward these concrete types to the implemented interfaces.
Complexity
This functionality has to cover a lot of edge cases and will not be easy to implemented.
Generics passed to the interface implemented on non-generic contract
This should be fairly simple as there is no intersection between generics from the interface and the contract.
#[contract]
impl<ExecT, QueryT> Generic<ExecT, QueryT> for NonGeneric {}
Concrete types passed to the interface implemented on non-generic contract
At this stage we would have to detect which generic arguments are also generic parameters defined in impl block. Mechanism for that should be fairly simple, but good coverage is required to detect every place it should be appllied.
#[contract]
impl Generic<SvCustomMsg, SvCustomMsg> for NonGeneric {}
Generic types passed to the interface implemented on generic contract
Here generics might overlap in generated code. We have to filter the duplications. GlueMessage will for sure require change as it generates the wrapper message for exec and query.
There is a possibility that message will have two parameters that are of the same generic type. While parsing used generics we should forward it only once to generated types and traits.
When implementing the interface instead of forwarding the generics we could use a concrete type. In current behavior only if types of two parameters were the same one would be omitted which in case of a single generic parameter ParamT like above would be good. However in the example below both <String, String> should be forwarded to the Querier and other types generated by the interface macro.
It should be very hard to achieve support for both of these cases and solution should be to use the InterfaceApi and forward there all the generic arguments.
Currently the examples consider single message per type. It should be confirmed that multiple messages are supported.
I think two messages per type with one generic unique and one shared should cover all of the cases. Unfortunately this most likely will make the examples unreadable due to overflow of generic types.
With version
0.9.0
users are able to define generics in their contracts and interfaces. Although contracts generics can be set as any concrete types by users importing these contracts to their own it is impossible to forward these concrete types to the implemented interfaces.Complexity
This functionality has to cover a lot of edge cases and will not be easy to implemented.
Generics passed to the interface implemented on non-generic contract
This should be fairly simple as there is no intersection between generics from the interface and the contract.
Concrete types passed to the interface implemented on non-generic contract
At this stage we would have to detect which generic arguments are also generic parameters defined in
impl
block. Mechanism for that should be fairly simple, but good coverage is required to detect every place it should be appllied.Generic types passed to the interface implemented on generic contract
Here generics might overlap in generated code. We have to filter the duplications.
GlueMessage
will for sure require change as it generates the wrapper message forexec
andquery
.Concrete types passed to the interface implemented on generic contract
Same as in case of non-generic contract we have to detect the concrete types and not pass them to generated types as generics.
Separate generic types passed to the interface
Some types passed to the interface might be generics and some concrete types. We should filter out the concrete types from the generics.
Behavior differ in
execs
andqueries
and even in parameters and return types and we have to cover all of these cases.Duplicated type in signatures
There is a possibility that message will have two parameters that are of the same generic type. While parsing used generics we should forward it only once to generated types and traits.
or
Should generate
When implementing the interface instead of forwarding the generics we could use a concrete type. In current behavior only if types of two parameters were the same one would be omitted which in case of a single generic parameter
ParamT
like above would be good. However in the example below both<String, String>
should be forwarded to theQuerier
and other types generated by theinterface
macro. It should be very hard to achieve support for both of these cases and solution should be to use theInterfaceApi
and forward there all the generic arguments.Multiple messages
Currently the examples consider single message per type. It should be confirmed that multiple messages are supported. I think two messages per type with one generic unique and one shared should cover all of the cases. Unfortunately this most likely will make the examples unreadable due to overflow of generic types.