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-7776] Misleading 'flatMap is unavailable' diagnostic on Sequence #50315

Closed
AnthonyLatsis opened this issue May 25, 2018 · 3 comments
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation

Comments

@AnthonyLatsis
Copy link
Collaborator

Previous ID SR-7776
Radar None
Original Reporter @AnthonyLatsis
Type Bug
Status Closed
Resolution Done

Attachment: Download

Environment

Version 9.3 (9E145)

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

md5: c214929280d7ffbae26c384ba79d8054

Issue Description:

The last two examples should show ambiguous reference and optionally generic parameter could not be inferred. Maybe a logic imperfection related to @available? (One of the flatMap methods is deprecated).

protocol P { // test
  associatedtype Element

  func foo<U>(_ arg: (Element) throws -> U) rethrows -> [U.Element] where U: P
  func foo<U>(_ arg: (Element) throws -> U?) rethrows -> [U]
}

func g<T: P>( arg: T) {
  arg.foo // Ambiguous reference to member 'foo' (OK)
}

func g<T: Sequence>( arg: T) {
  arg.flatMap // 'flatMap' is unavailable
}
[1, 2, 3].enumerated().flatMap // 'flatMap' is unavailable
@belkadan
Copy link
Contributor

I see it in near-master, so maybe it's fixed?

@AnthonyLatsis
Copy link
Collaborator Author

By the way, I am getting this note

note: 'flatMap' was obsoleted in Swift 4
@inlinable public func flatMap(_ transform: (Self.Element) throws -> String) rethrows -> [String]

Was the 'String' flatMap really on Sequence before? This would explain the compiler actually resolving flatMap as a reference to an obsoleted method. The diagnostic then makes sense...but only with the note attached and containing the method's full signature, which isn't shown.

In addition, Xcode doesn't show inline notes, which often makes errors senseless like here.
![](Screen Shot 2018-05-26 at 4.48.17 PM.png)

@AnthonyLatsis
Copy link
Collaborator Author

This diagnoses fine in Xcode 11.0

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

No branches or pull requests

2 participants