The question is, as far as I understand:
class C<T, U> where T : class, U where U : class { }
class D<T, U> where T : class, U { }
Is there a law legal for D
that is not legal for C
?
Not if U
and T
are private types. That is, types in which there are no type parameters. As John Hannah says, an open type can cause a problem:
class N<T, U> where T : class, U { C<T, U> c; D<T, U> d; }
D
, .
, , :
C
U
.
D
, T
, , . U
T
T
, - T
( ) . , U
.
, #, CLR, JIT , U
! # , , U
, , U
.
, a U
, , , - , , . , , , , , , .
, .
:
, ,
class B<T> { public virtual void M<U>(U u) where U : T {} }
class D : B<int> { public override void M<U>(U u) { } }
, # , where U : int
. M
- , int.
IL, CLR , " -- " . codegen , -, , jit , , # 2.