Bugzilla – Bug 324625
[GMCS] Nested class with generic code produces error (CS0305) while MS.NET does not
Last modified: 2009-09-07 17:35:09 UTC
---- Reported by knocte@gmail.com 2007-06-26 11:04:34 MST ---- Testcase is: using System.Collections.Generic; namespace gmcsGenericsBug { public class BaseClass<T, O> { public class NestedClassInsideBaseClass<K, V> { } public List<NestedClassInsideBaseClass<T, O>> Items { get { return null; } } } public class DerivedClass : BaseClass<int, string> { public DerivedClass() { foreach (NestedClassInsideBaseClass<int, string> oPair in this.Items) { } } } } Results: Using the generic type `gmcsGenericsBug.BaseClass<T,O>.NestedClassInsideBaseClass<K,V>' requires 4 type arguments (CS0305). Expected results (MS.NET): [No compilation errors.] ---- Additional Comments From knocte@gmail.com 2007-07-02 03:08:39 MST ---- Without using the nested class, all works ok. ---- Additional Comments From knocte@gmail.com 2007-07-03 09:47:30 MST ---- In case my last comment is confusing, I mean, transforming the testcase to have the nested class as a normal (not-nested) class.
I am the reporter.
Here is a simpler test case with the same results: using System; namespace GenericTest { public class OuterGeneric<T> { public class InnerGeneric<U> { public static string GetTypeNames() { return typeof(T).ToString() + " " + typeof(U).ToString(); } } } class Program { static void Main(string[] args) { string typeNames = OuterGeneric<int>.InnerGeneric<long>.GetTypeNames(); Console.WriteLine(typeNames); } } }
*** Bug 529691 has been marked as a duplicate of this bug. ***
Another take on the bug: public class MyList<T> { public class Helper <U, V> {} public Helper<U,V> GetHelper<U,V> () {return null;} } gmcs -unsafe -t:library b-dt.cs b-dt.cs(5,12): error CS0305: Using the generic type `MyList<T>.Helper<U,V>' requires `3' type argument(s) CSC compiles w/o error.
Fixed in trunk.