[Mono-devel-list] Warnings building mcs/mcs

Ben Maurer bmaurer at users.sourceforge.net
Sun Jan 4 21:18:06 EST 2004


On Sun, 2004-01-04 at 20:56, Nick Drochak wrote:
> Thanks. I'm afraid my question was too terse.  I understand the problem and
> "how" to fix it, but wanted to get mcs's hackers to comment on the
> right/best way to fix this problem.

The code for the method is:

		public override bool Equals (object obj)
		{
			TypeExpr tobj = obj as TypeExpr;
			if (tobj == null)
				return false;

			return Type == tobj.Type;
		}

so, obviously, the criteria for equality is that the two TypeExpr's
types are the same. If the two types must be the same, it follows that
the hashcode of the two types must be the same. So a valid
implementation would be:

return this.Type;

Because, it follows the requirement for the Equals and GetHashcode,

a.Equals (b) ==> a.GetHashCode () == b.GetHashCode ()

-- Ben




More information about the Mono-devel-list mailing list