You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inheritance and type narrowing prevent private member access in base class. #11454
Expected behavior:
Should be able to access private member in its declaring class.
Actual behavior:
Cannot access private member in its declaring class if the subclasses have different members and we narrow the type of this to a union type of its subclasses.
Just looking at old bugs; this one was fixed in 3.9+ via #38277, though I'm not sure that the PR actually introduces a test for this particular case (though the underlying thing is in fact the same; this is narrowed to (this & Cat) | (this & Dog)).
Activity
falsandtru commentedon Oct 9, 2016
I think
thisnarrowed by subclasses should have external accessibility of them. So I think this is a correct behavior.normalser commentedon Oct 9, 2016
I think it should work. Works in Java. https://goo.gl/Pb5p2Y
mhegazy commentedon Dec 14, 2016
So we should narrow to
Cat & Animal | Dog & Animal?jakebailey commentedon Jul 6, 2023
Just looking at old bugs; this one was fixed in 3.9+ via #38277, though I'm not sure that the PR actually introduces a test for this particular case (though the underlying thing is in fact the same;
thisis narrowed to(this & Cat) | (this & Dog)).