
Signature
Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)
Thanks Oliver for the answer.
> class A {
> public virtual void Foo<T>() where T: ISomething {
[quoted text clipped - 7 lines]
>
> This code compiles.
yes, because the constraint is inherited. This can be seen also in the
bytecode where
B::Foo looks B::Foo<(ISomething) T>()
> that
> these constraints couldn't be more restrictive than those on the
> overridden method. But when I tried to test this by changing the method
> signature of B.Foo to this:
>
> public override void Foo<T> where T: ISomething, new()
but you're more restrictive here by adding "new()". anyway, even if you are
not more restrictive, the verifier rejects.
> I really have no idea from the top of my head what
> this paragraph is talking about.
I really think that this "no more restrictive than" has to do with the
subtyping relation, BUT it's not currently implemented like that in the
verifier (Version 2.0.50215.44).
George
Oliver Sturm - 21 Sep 2005 19:54 GMT
>> public override void Foo<T> where T: ISomething, new()
>
[quoted text clipped - 7 lines]
>subtyping relation, BUT it's not currently implemented like that in the
>verifier (Version 2.0.50215.44).
What I really wanted to say with my post is that nothing seems to be
rejected on the basis of being more or less restrictive in a derived class
- the message says that putting constraints on overridden methods in
derived classes is outright forbidden. That's why I said I don't
understand the paragraph because it really seems to specify something
completely useless.
Oliver Sturm

Signature
Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)
George - 21 Sep 2005 21:37 GMT
> That's why I said I don't
> understand the paragraph because it really seems to specify something
> completely useless.
Oliver, you were referring to C# while I was actually pointing to CIL
bytecode.
In the bytecode, you are allowed to write the same constraint in the
overriding method or to write none (which is the same as writing object). At
least, this is allowed by the current verifier ... although ECMA states that
it shall allow more.
George