{
if (tparams != null) {
type_params = new TypeParameter[tparams.Length];
+ var src = new TypeParameterSpec[tparams.Length];
+ var dst = new TypeParameterSpec[tparams.Length];
+
for (int i = 0; i < type_params.Length; ++i) {
type_params[i] = tparams[i].CreateHoistedCopy (this, spec);
+
+ src[i] = tparams[i].Type;
+ dst[i] = type_params[i].Type;
+ }
+
+ // A copy is not enough, inflate any type parameter constraints
+ // using a new type parameters
+ var inflator = new TypeParameterInflator (null, src, dst);
+ for (int i = 0; i < type_params.Length; ++i) {
+ src[i].InflateConstraints (inflator, dst[i]);
}
}
}
ec.Emit (OpCodes.Ldftn, TypeBuilder.GetMethod (t.GetMetaInfo (), (MethodInfo) delegate_method.GetMetaInfo ()));
} else {
+ if (delegate_method.IsGeneric)
+ delegate_method = delegate_method.MakeGenericMethod (method.TypeParameters);
+
ec.Emit (OpCodes.Ldftn, delegate_method);
}
--- /dev/null
+using System;
+
+class C<T> where T : C<T>
+{
+ public static void Foo<U> (U arg) where U : C<U>, new ()
+ {
+ var i = new U ();
+ {
+ var ii = new U ();
+ Func<U> f = () => i;
+ {
+ Action a = () => C<U>.Run (ii);
+ a ();
+ }
+ f ();
+ }
+ }
+
+ static void Run (T a)
+ {
+ }
+}
+
+class D : C<D>
+{
+}
+
+class E : C<E>
+{
+}
+
+class A
+{
+ public static int Main ()
+ {
+ D.Foo (new E ());
+ return 0;
+ }
+}
\ No newline at end of file