[SR-220] Compiler unable to resolve types properly
| Previous ID | SR-220 |
| Radar | None |
| Original Reporter | nikita (JIRA User) |
| Type | Bug |
Additional Detail from JIRA
| Votes | 0 |
| Component/s | |
| Labels | Bug |
| Assignee | None |
| Priority | Medium |
md5: d26c0323af50329b2f99c14b0d199518
Issue Description:
struct A<B: CollectionType> {
init(c: B) {
c.startIndex.advancedBy(Int(5), limit: c.endIndex)
}
}
declaration above fails with error:
error: cannot invoke 'advancedBy' with an argument list of type '(Int, limit: B.Index)'
c.startIndex.advancedBy(Int(5), limit: c.endIndex)
replacing Int(5) with 5 makes it compile properly. I was not able to reduce this case further yet, but there should be simple example of the case for sure.
Is this really a bug?
Note that the CollectionType's associated type Index doesn't have to be an Int.
So another way to get your example to compile is to add the following where clause (and thereby constraining it to work only with CollectionTypes whose Index is an Int):
struct A<B: CollectionType where B.Index == Int> {
init(c: B) {
c.startIndex.advancedBy(Int(5), limit: c.endIndex)
}
}
Specifically, it's not the Index that is or isn't an Int, but the Index's distance type. But the error message ought to say what overload was expected.
I think this bug has become invalid, and should be closed as either `Invalid` or `Cannot Reproduce`.
The APIs involved have since been reshaped and the reproducer has become stale. The error now says value of type 'B.Index' has no member 'advancedBy'.