Proposal: Allow variance on interface implementation #296
Unanswered
huoyaoyuan
asked this question in
General
Replies: 2 comments
-
What is EIMI? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When the member method's signature does not exactally equal to the interface member, but suitable to the variance rule, let the compiler generate an EIMI method to do the convertion.
The variance rule here can be more wider than delegate/interface, since boxing can be done in the generated method.
Sample:
The most famous sample is
IEnumerable<T>
. It inherits fromIEnumerable
, which contains a methodGetEnumerator()
that has same name but different return type, so every class implements it has to provide an EIMI method.Generated:
And in the case that a public
IEnumerator<T> GetEnumerator()
is provided, the EIMIIEnumerable.GetEnumerator()
can also be generated.Question
Does CLR requires exactly same signature on interface implementing (in verifiable code)?
If not, EIMI mothod that just does implicit reference conversions can be skipped. Boxing conversions always need one.
Beta Was this translation helpful? Give feedback.
All reactions