Repository navigation
binding: let derived class fields and properties hide base members - #53
Merged
Merged
Conversation
For a class, Type.GetMembers returns a field of a derived class along with the base class field it hides, and likewise for a property unless both properties have the same type. Accessing such a member, through a value or by an unqualified name in the context, failed with "Ambiguous match found". As in C#, a field or property of a derived class now hides the members with the same name of its base classes, as it already did for derived interfaces. Members of statically imported types are still not filtered: a name declared in two imported types is ambiguous even if one type derives from the other, as with using static in C#.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A field or property redeclared in a derived class could not be accessed. For a class,
Type.GetMembersreturns both the member of the derived class and the base class member it hides, so the lookup reported an ambiguous match. For a context memberDerivedof a class that redeclaresint Fieldwithnewand replacesint Propertywithnew string Property,Derived.FieldandDerived.Propertyfailed with "Ambiguous match found", and so didFieldwhen the context object itself was of that class. A property redeclared with the same type was not affected: reflection drops the hidden property itself.This PR applies the rule that #50 added for interfaces to classes: as in C#, a field or property of a derived class hides the members with the same name of its base classes.
Members of statically imported types are still not filtered. A name declared in two imported types stays ambiguous even if one type derives from the other, like CS0229 with
using staticin C#.