Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Henry <ludovic@xamarin.com>2015-09-14 12:23:38 +0300
committerLudovic Henry <ludovic@xamarin.com>2015-09-17 18:37:12 +0300
commit77de476c44946c2df0477d7e6031d9b6bf113014 (patch)
treed28527708f10ee09a6c4a80788ce8878d3dd415c /mcs/class/corlib/System/Delegate.cs
parent20f555aefba1f7c6789695cd2529f229d7cd36ff (diff)
[delegate] Fix Equals on Delegate to virtual method
The comparison was failing because we were still using the method field (instead of the Method property), which would then return, in the case of a delegate to a virtual function, the method on the base class, instead of the method on the derived class. Updated the test cases to check that too.
Diffstat (limited to 'mcs/class/corlib/System/Delegate.cs')
-rw-r--r--mcs/class/corlib/System/Delegate.cs15
1 files changed, 6 insertions, 9 deletions
diff --git a/mcs/class/corlib/System/Delegate.cs b/mcs/class/corlib/System/Delegate.cs
index ba97e726509..76869d6d430 100644
--- a/mcs/class/corlib/System/Delegate.cs
+++ b/mcs/class/corlib/System/Delegate.cs
@@ -475,13 +475,15 @@ namespace System
return MemberwiseClone ();
}
- internal bool Compare (Delegate d)
+ public override bool Equals (object obj)
{
+ Delegate d = obj as Delegate;
+
if (d == null)
return false;
-
+
// Do not compare method_ptr, since it can point to a trampoline
- if (d.m_target == m_target && d.method == method) {
+ if (d.m_target == m_target && d.Method == Method) {
if (d.data != null || data != null) {
/* Uncommon case */
if (d.data != null && data != null)
@@ -500,14 +502,9 @@ namespace System
return false;
}
- public override bool Equals (object obj)
- {
- return Compare (obj as Delegate);
- }
-
public override int GetHashCode ()
{
- return method.GetHashCode () ^ (m_target != null ? m_target.GetHashCode () : 0);
+ return Method.GetHashCode () ^ (m_target != null ? m_target.GetHashCode () : 0);
}
protected virtual MethodInfo GetMethodImpl ()