diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f6185b61..0da350cef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ details about the cause of the failure - Indexers can now be used with interface objects - Fixed a bug where indexers could not be used if they were inherited - Made it possible to use `__len__` also on `ICollection<>` interface objects +- Made it possible to call `ToString`, `GetHashCode`, and `GetType` on inteface objects ### Removed diff --git a/src/runtime/classmanager.cs b/src/runtime/classmanager.cs index 26d0536ab..c8bed6bc4 100644 --- a/src/runtime/classmanager.cs +++ b/src/runtime/classmanager.cs @@ -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++) diff --git a/src/tests/test_interface.py b/src/tests/test_interface.py index 4546471f2..130bd71c1 100644 --- a/src/tests/test_interface.py +++ b/src/tests/test_interface.py @@ -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() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy