Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-11725] No fixit to add stubs when conforming to Sequence or Collection #54134

Open
NevinBR opened this issue Nov 6, 2019 · 3 comments
Open
Labels
associated type inference bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself conformances Feature → protocol: protocol conformances diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis

Comments

@NevinBR
Copy link
Contributor

NevinBR commented Nov 6, 2019

Previous ID SR-11725
Radar rdar://problem/56966686
Original Reporter @NevinBR
Type Bug
Environment

Swift 5.1.2
Xcode 11.2
MacOS 10.14.6

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, AssociatedTypeInference, DiagnosticsQoI, ProtocolConformance, TypeChecker
Assignee None
Priority Medium

md5: 030b94e281d5eec3d58ed988895cfc10

Issue Description:

When conforming a type to Sequence or Collection, there is a “does not conform” error as expected, but no fixit to add stubs:

struct Foo: Collection {}
// Error: Type 'Foo' does not conform to protocol 'Collection'
// No fixit is offered
@beccadax
Copy link
Contributor

beccadax commented Nov 7, 2019

@swift-ci create

@theblixguy
Copy link
Collaborator

It seems like associated type inference is preventing fix-its from being generated:

/Users/suyashsrijan/Documents/swift-src/swift/stdlib/public/core/Collection.swift:349:18: note: unable to infer associated type 'Index' for protocol 'Collection'
  associatedtype Index: Comparable
                 ^
/Users/suyashsrijan/Documents/swift-src/swift/stdlib/public/core/Range.swift:894:10: note: candidate can not infer 'Index' = '(UnboundedRange_) -> ()' because '(UnboundedRange_) -> ()' is not a nominal type and so can't conform to 'Comparable'
  public subscript(x: UnboundedRange) -> SubSequence {

If you specify the type for Index, then the fix-its are offered:

struct Foo: Collection {
  typealias Index = SomeType // <-- Add this
}

@NevinBR
Copy link
Contributor Author

NevinBR commented Feb 5, 2020

If you specify the type for Index, then the fix-its are offered:

struct Foo: Collection {
  typealias Index = SomeType // <-- Add this
}

That is what I expect the fix-it to offer.

My memory of previous versions of Swift is that there used to be a fix-it to add exactly that.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
associated type inference bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself conformances Feature → protocol: protocol conformances diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants