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-2654] NSAttributedString import creates indistinguishable candidates due to automatic defaulting #45259

Open
swift-ci opened this issue Sep 15, 2016 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-2654
Radar None
Original Reporter erica (JIRA User)
Type Bug
Environment

Swift 3, Xcode 8

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

md5: ae4e7606fcf837355a888c76b7d04cd4

relates to:

  • SR-2838 renamification creates ambiguity

Issue Description:

Autodefaulting makes these indistinguishable:

  • initWithHTML:documentAttributes:

  • initWithHTML:options:documentAttributes:

Error: "Playground execution failed: error: MyPlayground.playground:34:18: error: ambiguous use of 'init(HTML:documentAttributes:)'
let attributed = NSAttributedString(HTML: data, documentAttributes: nil)"

Workaround: add options with manual [:] argument.

Long term solution: probably omitting the options-free API

@belkadan
Copy link
Contributor

We should be preferring the shorter one, but unfortunately our logic in this area doesn't like it when the defaulted arguments aren't at the end. The importer could choose not to default arguments that aren't at the end, but that would affect methods that aren't overloaded on import. Both of these changes would be source-breaking, too.

In this specific case, we could probably mark the first one as unavailable. @phausler, any opinion?

(Note that things are even worse than usual because the HTML is lowercased upon import, so any diagnostics you're getting are about the Swift 2 names, which are then themselves marked unavailable. But using html produces the same issue.)

@phausler
Copy link
Member

This shouldn't be marked as unavailable; the compiler shouldn't make ambiguous default arguments. IMHO this looks like a duplicate of https://bugs.swift.org/browse/SR-1408

@belkadan
Copy link
Contributor

We probably can't do either of the things I suggested because it would be source-breaking, and we missed the cutoff for Swift 3.0. I'm asking if you want to do something for this particular API despite 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
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants