bamboo/boo — pull request #41 by aaronlerch (2012-12-07 15:07:39+00:00)
Title: Explicit cast to IDictionary to retrieve the correct enumerator

The generic Dictionary implementation also implements
IDictionary. Under the covers it uses explicit interface implementations
to return a different IDictionaryEnumerator for GetEnumerator()
depending on how it's accessed. The Boo.Lang.Hash class uses a generic
dictionary internally for its data structure, and has an excplicit
interface implementation for IDictionary.GetEnumerator(), but doesn't
subsequently cast the private dictionary to IDictionary as well,
resulting in the incorrect IDictionaryEnumerator being returned.

The result is any callers doing something like:
foreach (DictionaryEntry entry in myBooHashVariable)
{ }
will throw an InvalidCastException, as the enumerator for
Dictionary returns a KeyValuePair and not a
DictionaryEntry.

Simply "continuing" the excplicit cast to IDictionary returns the
correct enumerator.

(debugging also courtesy of @craigdneo)