Skip to content

binding: look up members of base interfaces and Object for interfaces - #50

Merged
rameel merged 1 commit into
mainfrom
binding/interface-members
Nov 20, 2026
Merged

rameel merged 1 commit into
mainfrom
binding/interface-members

Conversation

@rameel

@rameel rameel commented Nov 20, 2026

Copy link
Copy Markdown
Owner

An interface type exposed only the members it declares. With a context member IList<int> List, List.Count, List.Contains(2), and List.GetEnumerator() failed with "Cannot resolve symbol", and ToString() or GetHashCode() could not be called on any interface-typed value. An indexer declared in a base interface was not found either.

This PR looks up the members of an interface type in the interface, its base interfaces, and Object, as C# does:

  • a field or property of a derived interface hides the members with the same name of its base interfaces;
  • a method of a derived interface hides the method with the same signature of a base interface or Object, so List.GetEnumerator() returns IEnumerator<int>;
  • a member declared in two unrelated base interfaces, such as Count of an interface that extends both IList<int> and IReadOnlyList<int>, is reported as an ambiguous match, like CS0229 in C#.

Static members of base interfaces and Object are also available through the interface name. Unqualified names still use only the static members declared by the imported types, as using static does in C#. Lookup in classes does not change.

For an interface, Type.GetMembers and Type.GetMethods return only the
members the interface declares. A context member of type IList<int>
had no Count, Contains, or GetEnumerator, no interface-typed value had
ToString or GetHashCode, and an indexer declared in a base interface
was not found.

As in C#, also look up the members of the base interfaces and Object.
A field or property of a derived interface hides the members with the
same name of its base interfaces, and a method hides the method with
the same signature of a base interface or Object. A member declared in
two unrelated base interfaces, such as Count of an interface that
extends both IList<int> and IReadOnlyList<int>, is reported as an
ambiguous match.

Static members of base interfaces and Object are also found through
the interface name. Unqualified names still use only the static
members declared by the imported types, as with using static in C#.
@rameel
rameel merged commit d9e1cfd into main Nov 20, 2026
1 check passed
@rameel
rameel deleted the binding/interface-members branch November 20, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant