for (int current = 0; current < count; current++)
{
- int level = GetDerivedLevel (match[current].DeclaringType);
+ MethodBase m = match [current];
+ int level = GetDerivedLevel (m.DeclaringType);
if (level == highLevel)
throw new AmbiguousMatchException ();
+ // If the argument types differ we
+ // have an ambigous match, as well
+ if (matchId >= 0) {
+ ParameterInfo[] p1 = m.GetParameters ();
+ ParameterInfo[] p2 = match [matchId].GetParameters ();
+ bool equal = true;
+
+ if (p1.Length != p2.Length)
+ equal = false;
+ else {
+ int i;
+
+ for (i = 0; i < p1.Length; ++i) {
+ if (p1 [i].ParameterType != p2 [i].ParameterType) {
+ equal = false;
+ break;
+ }
+ }
+ }
+
+ if (!equal)
+ throw new AmbiguousMatchException ();
+ }
if (level > highLevel)
{
+2007-11-05 Mark Probst <mark.probst@gmail.com>
+
+ * Binder.cs: Treat matches with different argument types as
+ ambiguous, too. Fixes #324998.
+
2007-11-01 Zoltan Varga <vargaz@gmail.com>
* Binder.cs: Avoid returning a method with a ParamArray attribute when a normal
{
public new void Foo (Bug76083ArgBase a) {}
}
+
+ private const BindingFlags BUG324998_BINDING_FLAGS
+ = BindingFlags.Public | BindingFlags.NonPublic
+ | BindingFlags.Instance | BindingFlags.Static
+ | BindingFlags.IgnoreCase;
+
+ class Bug324998AGood { public virtual void f(int i1, int i2, bool b) {} }
+
+ class Bug324998BGood : Bug324998AGood { public override void f(int i1, int i2, bool b) {} }
+
+ class Bug324998ABad {
+ public virtual void f(int i1, int i2) {}
+ public virtual void f(int i1, int i2, bool b) {}
+ }
+
+ class Bug324998BBad : Bug324998ABad { public override void f(int i1, int i2, bool b) {} }
+
+ [Test]
+ public void Bug324998Good () {
+ if (typeof(Bug324998BGood).GetMethod("f", BUG324998_BINDING_FLAGS) == null)
+ throw new Exception("Bug324998Good");
+ }
+
+ [Test]
+ [ExpectedException (typeof (AmbiguousMatchException))]
+ public void Bug324998Bad () {
+ typeof(Bug324998BBad).GetMethod("f", BUG324998_BINDING_FLAGS);
+ }
}
}
+2007-11-05 Mark Probst <mark.probst@gmail.com>
+
+ * BinderTests.cs: Add test for bug #324998.
+
2007-11-04 Miguel de Icaza <miguel@novell.com>
* ParameterInfoTest.cs: Add new test for testing the [Optional]