Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Ensure methods of Object are also available on interface objects#1284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
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
1 change: 1 addition & 0 deletionsCHANGELOG.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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

Expand Down
11 changes: 11 additions & 0 deletionssrc/runtime/classmanager.cs
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionssrc/tests/test_interface.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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()

[8]ページ先頭

©2009-2025 Movatter.jp