Replies: 3 comments
-
I think that this is covered by #113 and you can also have a look here #399. |
Beta Was this translation helpful? Give feedback.
0 replies
-
No, #113 is something else, but #399 has the same intention with slightly different syntax. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks, I was unaware of them. #399 in particular looks like the same area. |
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
Uh oh!
There was an error while loading. Please reload this page.
-
In C#, I frequently want to express a type as interface that implements a number of interfaces. I can derive an interface as so...
interface IDerived : IBase1, IBase2, ... {
}
and declare the signature of a method like so...
void MyMethod(IDerived arg) {
}
but that requires the argument to explicitly derive from IDerived (which is not possible for types I have not defined). What I would really want to express is simply that the type of this variable is the union of the types of the inherited interfaces.
For example, would like to be able to declare...
void MyMethod((IBase1 + IBase2) arg);
(Note - the syntax here is purely expository, not a serious suggestion. I suspect it may clash with other language constructs).
Alternatively, allow declaring types like IDerived...
union IDerived : IBase1, IBase2;
And allow objects that implement IBase1 and IBase2 to conform to the type of IDerived.
As a concrete example, it may be desirable to declare an argument as being a union of IList, INotifyCollectionChanged and INotifyPropertyChanged. Many existing types implement these interfaces, but it is impossible to express in a (statically) type safe manner that an argument must implement all these interfaces that may be satisfied by objects of existing classes.
Beta Was this translation helpful? Give feedback.
All reactions