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
Apple Swift version 2.2 (swiftlang-703.0.18.8 clang-703.0.31)
Target: x86_64-apple-macosx10.9
Additional Detail from JIRA
Votes
0
Component/s
Labels
Bug
Assignee
None
Priority
Medium
md5: e06491478ba3becdc45a66a1787453eb
duplicates:
SR-617Self not always resolved dynamically with Generics
Issue Description:
There seems to be an issue in the way static methods are dynamically dispatched when a protocol extension is involved.
IF the inferred type of a variable is the protocol:
AND the method is defined in the original protocol THEN the runtime type’s implementation is called, irrespective of whether there is a default implementation in the extension.
AND the method is not defined in the original protocol, THEN the default implementation is called.
ELSE IF the inferred type of the variable is the type THEN the type’s implementation is called.
When static variables are involved, the behaviour seems to be the opposite.
Consider the following code:
What's more, commenting out the reuseID declaration on the Reusable protocol (leaving only the implementation in the extension) seems to fix the problem.
The text was updated successfully, but these errors were encountered:
I think specifically it's your use of Self instead of self that makes the difference here. But I'm not 100% sure what the correct behavior is. @rjmccall, @jckarter?
Environment
Apple Swift version 2.2 (swiftlang-703.0.18.8 clang-703.0.31)
Target: x86_64-apple-macosx10.9
Additional Detail from JIRA
md5: e06491478ba3becdc45a66a1787453eb
duplicates:
Self
not always resolved dynamically with GenericsIssue Description:
There seems to be an issue in the way static methods are dynamically dispatched when a protocol extension is involved.
IF the inferred type of a variable is the protocol:
AND the method is defined in the original protocol THEN the runtime type’s implementation is called, irrespective of whether there is a default implementation in the extension.
AND the method is not defined in the original protocol, THEN the default implementation is called.
ELSE IF the inferred type of the variable is the type THEN the type’s implementation is called.
When static variables are involved, the behaviour seems to be the opposite.
Consider the following code:
This prints:
instead of the expected
What's more, commenting out the reuseID declaration on the Reusable protocol (leaving only the implementation in the extension) seems to fix the problem.
The text was updated successfully, but these errors were encountered: