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
This produces:
error: ambiguous use of 'foo'
_ = foo
^
Given the type constraint on the protocol, don't the 2 candidates have be the same? What's a situation where they'd differ? I tried adjusting the call site to
_ = (self as Foo).foo
_ = (self as Bar).foo
to compare results, but every time, it appears to call the same method. This is true whether foo is defined in a protocol extension or not, whether I'm calling run on a subclass of Bar or not.
The text was updated successfully, but these errors were encountered:
Although I don't believe it's currently possible to conform a subclass of Bar to Foo in such a way where Bar's foo property (or an override of it) isn't used in order to satisfy the conformance, it could be possible if we ever exposed a way for the user to satisfy a protocol requirement with a differently named member.
That being said, I recently implemented a ranking rule where the member on the concrete type (Bar in this case) is preferred over the protocol requirement – therefore your code will be unambiguous and compile in Swift 5.
Environment
Swift 4.2, Xcode 10
Additional Detail from JIRA
md5: eb6e35622ac1836f179e1c63153da001
duplicates:
Issue Description:
Possibly related to SR-7940
Consider the following:
This produces:
error: ambiguous use of 'foo'
_ = foo
^
Given the type constraint on the protocol, don't the 2 candidates have be the same? What's a situation where they'd differ? I tried adjusting the call site to
_ = (self as Foo).foo
_ = (self as Bar).foo
to compare results, but every time, it appears to call the same method. This is true whether foo is defined in a protocol extension or not, whether I'm calling run on a subclass of Bar or not.
The text was updated successfully, but these errors were encountered: