sunshine-protocol / sunshine

Governance + Bounty Platform
Other
43 stars 16 forks source link

Loose Inheritance (Inherit as Associated Type) Overloads Type Inference for Client #96

Closed 4meta5 closed 4 years ago

4meta5 commented 4 years ago

here's the error if we try to do inheritance through associated types -- for the client, I'll probably just use direct inheritance and will consider the benefits of indirect inheritance in the module context

error[E0277]: the trait bound `Self: srml::bank::Bank` is not satisfied
  --> client/src/srml/bounty.rs:56:5
   |
56 | /     type Bank: IDIsAvailable<OnChainTreasuryID>
57 | |         + IDIsAvailable<(OnChainTreasuryID, BankMapID, BankAssociatedId<Self>)>
58 | |         + GenerateUniqueID<OnChainTreasuryID>
59 | |         + SeededGenerateUniqueID<BankAssociatedId<Self>, (OnChainTreasuryID, BankMapID)>
...  |
68 | |         + CommitAndTransfer<Self::OrgId, Self::AccountId, BalanceOf<Self>, Self::IpfsReference>
69 | |         + TermSheetExit<Self::AccountId, BalanceOf<Self>>;
   | |__________________________________________________________^ the trait `srml::bank::Bank` is not implemented for `Self`
   |
help: consider further restricting `Self`
   |
28 | pub trait Bounty: System + Org + Vote + srml::bank::Bank {
   |                                       ^^^^^^^^^^^^^^^^^^

and this error repeats itself 60 times to highlight every individual trait bound and provide the same suggestion of direct inheritance

4meta5 commented 4 years ago

This isn't actually a problem for our runtime because I won't use this type of inheritance for now

as of https://github.com/sunshine-protocol/sunshine-node/pull/89/commits/f1b70edf9a197a705d56ef7403213c914b8b4e6b

but it will be necessary if we have ever two modules that need to use eachother (this is the situation for which inheritance through module Trait's associated types is useful)