Open natecook1000 opened 5 years ago
I reverted the change in question, however I can bring it back without breaking your code, because note that 'Element' is not a generic parameter of Iterator itself, but of its outer type. It should not be a candidate for inference.
So in your pitch (https://forums.swift.org/t/infer-associated-types-as-generic-parameters-more-eagerly/30833), only the generic parameters on the specific type conforming to a protocol P
should be candidates for P
's associated types? That makes sense.
Yes, that is correct. I believe it was an oversight that we always look at the "innermost" generic parameters even if the type is not generic.
Actually your code also relies on Sequence.Element := Tree\<Element> in the outermost type too, because the witness comes from the iterator's element type. So this would be another source break from my proposal unfortunately. Maybe the proposal isn't worth it?
Attachment: Download
Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug | |Assignee | @slavapestov | |Priority | Medium | md5: 55e235db0319c7b83e185abee50f3418Issue Description:
I have a
Tree
type that is generic overElement
, and defines a nested iterator that has its own element type implicitly declared asTree<Element>
. (See attached file.) This compiles without error in shipping Swift, but inswift-DEVELOPMENT-SNAPSHOT-2019-11-14-a
I get this error:I can fix the problem by changing the name of
Tree
's generic parameter toTreeElement
.