Bugzilla – Bug 324961
[GMCS] CS0310 not reported : generic types constraints not checked when generic types imbrication
Last modified: 2011-04-07 11:07:20 UTC
---- Reported by ericbesombes@gmail.com 2007-08-02 11:34:09 MST ---- Mcs does not report error CS0310 when generic types are imbricated whitout respecting type arguments contraints. Code: public class Class1 { public Class1 (int i) {} } public class Class2 <T> {} public class Class3 <T> where T : new() {} Error CS0310 is reported if we compile the following code: public class Class4 : Class3 <Class1> {} This is normal since Class1 doesn't respect the constraint 'where T : new()' of generic class Class3. Now, let's compile this: public class Class5 : Class2 <Class3 <Class1>> {} Compilation with Mcs succeeds while error CS0310 should be returned. In the same way : public class Class7 <T> : Class2 <Class3 <T>> {} Error CS0310 should be reported by Mcs since no constraint is defined for 'T' in Class7, whereas one constraint is defined for 'T' in Class3. Note: This bug doesn't depend on the constraint : it can be 'where T : new()' or 'where T : class' or any other. Unknown bug field "cf_op_sys_details" encountered while moving bug <cf_op_sys_details>Independant on the OS while this concerns Mcs (IL binary)</cf_op_sys_details> Unknown operating system unknown. Setting to default OS "Other".
Fixed in master