Open jepers opened 6 years ago
There's this notes in TSPL 4.2 saying
"If a conforming type satisfies the requirements for multiple constrained extensions that provide implementations for the same method or property, Swift uses the implementation corresponding to the most specialized constraints."
Perhaps my example programs have multiple implementations corresponding to equally specialized constraints?
Clearing up old bugs. Yes, your intuition was correct: the compiler considers the various overloads of foo
equally likely in the normal cases, but once you make the conformance of Q conditional, the implementations of foo
that depend on being a Q aren't valid as a choice for the unconditional P. What do you think we can do to make this clearer?
I think that question has to be answered by someone more knowledgeable than me, assuming they too think this is unexpected behavior. Please let me know if you think I should just close the bug.
Environment
Xcode 9.4, default toolchain and recent snapshots Xcode 10, default toolchain and recent snapshots (2018-06-05)Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, DiagnosticsQoI | |Assignee | None | |Priority | Medium | md5: ea85cc6b4e13a3635f0d0c391347d71fIssue Description:
First an example involving constrained protocol extensions:
And a simpler but similar example:
And a variant of the simple example showing that what wasn't allowed above, is allowed if we make S generic, so for example the following compiles successfully:
The first example also works if S is generic: