Bug 324625 (MONO81951) - [GMCS] Nested class with generic code produces error (CS0305) while MS.NET does not
Summary: [GMCS] Nested class with generic code produces error (CS0305) while MS.NET do...
Status: RESOLVED FIXED
: 529691 (view as bug list)
Alias: MONO81951
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.2.0
Hardware: Other All
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-26 18:04 UTC by Andres Aragoneses
Modified: 2009-09-07 17:35 UTC (History)
2 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:42:29 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.

Comment 2 Andres Aragoneses 2008-03-16 22:48:44 UTC
I am the reporter.
Comment 3 Anthony Burke 2008-12-11 20:27:10 UTC
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);
        }
    }
}
Comment 4 Andres Aragoneses 2009-08-12 14:34:00 UTC
*** Bug 529691 has been marked as a duplicate of this bug. ***
Comment 5 Jon Pryor 2009-09-03 19:09:44 UTC
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.
Comment 6 Marek Safar 2009-09-07 17:35:09 UTC
Fixed in trunk.