+2007-01-28 Raja R Harinath <rharinath@novell.com>
+
+ Fix #80531
+ * anonymous.cs (ScopeInfo.InflateParameters): New.
+ (AnonymousContainer.Resolve): Use it to redirect types of
+ delegate parameters.
+
2007-01-27 Raja R Harinath <rharinath@novell.com>
Fix #80530
get { return generic_method; }
}
+ public Parameters InflateParameters (Parameters ps)
+ {
+ if (generic_method == null)
+ return ps;
+
+ int n = ps.Count;
+ if (n == 0)
+ return ps;
+
+ Parameter[] inflated_params = new Parameter [n];
+ Type[] inflated_types = new Type [n];
+
+ for (int i = 0; i < n; ++i) {
+ Parameter p = ps [i];
+ Type it = InflateType (p.ExternalType ()).ResolveAsTypeTerminal (this, false).Type;
+ inflated_types [i] = it;
+ inflated_params [i] = new Parameter (it, p.Name, p.ModFlags, p.OptAttributes, p.Location);
+ }
+ return new Parameters (inflated_params, inflated_types);
+ }
+
public TypeExpr InflateType (Type it)
{
#if GMCS_SOURCE
{
public readonly Location Location;
- // An array list of AnonymousMethodParameter or null
- public readonly Parameters Parameters;
+ public Parameters Parameters;
//
// The block that makes up the body for the anonymous mehtod
ReturnType = return_type_expr.Type;
}
+ if (RootScope != null)
+ Parameters = RootScope.InflateParameters (Parameters);
+
aec = new EmitContext (
ec.ResolveContext, ec.TypeContainer,
RootScope != null ? RootScope : Host, Location, null, ReturnType,
+2007-01-28 Raja R Harinath <rharinath@novell.com>
+
+ * gtest-308.cs: New test based on #80531.
+
+2007-01-27 Raja R Harinath <rharinath@novell.com>
+
+ * gtest-307.cs: New test based on #80358.
+
2007-01-11 Raja R Harinath <rharinath@novell.com>
* gtest-302.cs: New test based on #80249.
--- /dev/null
+partial class Foo<T> {}
+partial class Foo<T> {
+ public delegate int F ();
+}
+
+class Bar {
+ static int g () { return 0; }
+ static int Main ()
+ {
+ Foo<int>.F f = g;
+ return f ();
+ }
+}
--- /dev/null
+using System;
+
+public class Test {
+ public static Comparison<U> WrapComparison<U>(Comparison<U> comparison)
+ {
+ return delegate(U x, U y) { return comparison(x, y); };
+ }
+
+ public delegate int MyComparison<V> (V x, V y);
+ public static MyComparison<W> WrapMyComparison<W>(MyComparison<W> myComparison)
+ {
+ return delegate(W x, W y) { return myComparison(x, y); };
+ }
+}
+
+public class Foo {
+ static int compare (int x, int y)
+ { return x - y; }
+ static int compare (string x, string y)
+ { return string.Compare (x, y); }
+ static void test (int i)
+ {
+ if (i != 0)
+ throw new Exception (""+i);
+ }
+ static void Main ()
+ {
+ Comparison<int> ci = Test.WrapComparison<int> (compare);
+ Comparison<string> cs = Test.WrapComparison<string> (compare);
+ Test.MyComparison<int> mci = Test.WrapMyComparison<int> (compare);
+ Test.MyComparison<string> mcs = Test.WrapMyComparison<string> (compare);
+ test (ci (1,1));
+ test (cs ("h", "h"));
+ test (mci (2,2));
+ test (mcs ("g", "g"));
+ }
+}
+