Skip to content

Commit

Permalink
Correctly import nested non-generic types inside generic containers u…
Browse files Browse the repository at this point in the history
…sed within same generic container. Fixes #13549
  • Loading branch information
marek-safar committed Jul 29, 2013
1 parent 90e4ae4 commit 02820da
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mcs/mcs/import.cs
Expand Up @@ -324,10 +324,9 @@ TypeSpec[] CreateGenericArguments (int first, MetaType[] tparams, DynamicTypeRea
// IFoo<A<T>> foo; // A<T> is definition in this case
// }
//
// TODO: Is full logic from CreateType needed here as well?
//
if (!IsMissingType (type) && type.IsGenericTypeDefinition) {
var targs = CreateGenericArguments (0, type.GetGenericArguments (), dtype);
var start_pos = spec.DeclaringType == null ? 0 : spec.DeclaringType.MemberDefinition.TypeParametersCount;
var targs = CreateGenericArguments (start_pos, type.GetGenericArguments (), dtype);
spec = spec.MakeGenericType (module, targs);
}
}
Expand Down
14 changes: 14 additions & 0 deletions mcs/tests/gtest-591-lib.cs
@@ -0,0 +1,14 @@
// Compiler options: -target:library

using System;

namespace A
{
public class B<T>
{
public abstract class C : System.IEquatable<C>
{
public abstract bool Equals (C other);
}
}
}
13 changes: 13 additions & 0 deletions mcs/tests/gtest-591.cs
@@ -0,0 +1,13 @@
// Compiler options: -r:gtest-591-lib.dll

using System;

public class E
{
public System.Collections.Generic.Dictionary<int, A.B<int>.C> F;
public static void Main ()
{
var e = new E ();
Console.WriteLine (e.F);
}
}
10 changes: 10 additions & 0 deletions mcs/tests/ver-il-net_4_5.xml
Expand Up @@ -18388,6 +18388,16 @@
</method>
</type>
</test>
<test name="gtest-591.cs">
<type name="E">
<method name="Void Main()" attrs="150">
<size>19</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
</test>
<test name="gtest-anontype-01.cs">
<type name="Test">
<method name="Int32 Main()" attrs="150">
Expand Down

0 comments on commit 02820da

Please sign in to comment.