Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Ensure methods of Object are also available on interface objects
  • Loading branch information
danabr committed Nov 17, 2020
commit f5db45eaf34adaf2d0bfdcfea7dc825db16c30d0
11 changes: 11 additions & 0 deletions src/runtime/classmanager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,17 @@ private static ClassInfo GetClassInfo(Type type)
}
}
}

// All interface implementations inherit from Object,
// but GetMembers don't return them either.
var objFlags = BindingFlags.Public | BindingFlags.Instance;
foreach (var mi in typeof(object).GetMembers(objFlags))
{
if (local[mi.Name] == null)
{
items.Add(mi);
}
}
}

for (i = 0; i < items.Count; i++)
Expand Down
11 changes: 11 additions & 0 deletions src/tests/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,14 @@ def test_interface_collection_iteration():
untyped_list.Add(elem)
for e in untyped_list:
assert type(e).__name__ == "int"


def test_methods_of_Object_are_available():
"""Test calling methods inherited from Object"""
import System
clrVal = System.Int32(100)
i = System.IComparable(clrVal)
assert i.Equals(clrVal)
assert clrVal.GetHashCode() == i.GetHashCode()
assert clrVal.GetType() == i.GetType()
assert clrVal.ToString() == i.ToString()