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-7069] Autocomplete dropdown thinks optional protocol methods are IUOs #49617

Closed
lilyball mannequin opened this issue Feb 24, 2018 · 6 comments
Closed

[SR-7069] Autocomplete dropdown thinks optional protocol methods are IUOs #49617

lilyball mannequin opened this issue Feb 24, 2018 · 6 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. code completion Area → source tooling: code completion source tooling Area: IDE support, SourceKit, and other source tooling

Comments

@lilyball
Copy link
Mannequin

lilyball mannequin commented Feb 24, 2018

Previous ID SR-7069
Radar rdar://problem/37904574
Original Reporter @lilyball
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Xcode 9.2 (9C40b)
Apple Swift version 4.0.3 (swiftlang-900.0.74.1 clang-900.0.39.2)
Target: x86_64-apple-macosx10.9

Additional Detail from JIRA
Votes 0
Component/s CodeCompletion
Labels Bug
Assignee @rintaro
Priority Medium

md5: 46a44ad16a716b0b227fc5dea7ef94da

Issue Description:

The Xcode autocomplete dropdown mistakenly believes that optional protocol methods are IUOs when in fact they're just regular optionals.

@objc protocol Foo {
    @objc optional func bar()
}

func foo(_ foo: Foo) {
    foo.bar // autocomplete this
}

![](Screen Shot 2018-02-23 at 4.38.49 PM.png)

I know it's a regular optional because trying to call it like foo.bar() throws an error that says I didn't unwrap (() -> ())?.

@belkadan
Copy link
Contributor

May or may not actually be the code completion logic's fault, but let's start there.

@swift-ci create

@belkadan
Copy link
Contributor

Ah, that isn't actually supposed to mean IUO. It means the method must be unwrapped when you call it. (That is, that's showing what text will be inserted by code completion, not how the method is declared.)

@lilyball
Copy link
Mannequin Author

lilyball mannequin commented Feb 28, 2018

And yet accepting the suggestion doesn't insert the !.

@lilyball
Copy link
Mannequin Author

lilyball mannequin commented Feb 28, 2018

It's also a bit confusing because this definitely shows type information that won't be inserted. For example, self.encode plus autocomplete shows encode(to: Encoder) throws, but obviously the throws isn't inserted text.

@belkadan
Copy link
Contributor

belkadan commented Mar 1, 2018

Fair enough. cc @rintaro

@AnnaZaks
Copy link
Mannequin

AnnaZaks mannequin commented Jul 23, 2019

This should have been fixed by #16910
Eridius (JIRA User), , Could you verify if the problem is fixed and if so move the JIRA to "Closed"?

Thanks!
Anna

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the source tooling Area: IDE support, SourceKit, and other source tooling label Feb 6, 2023
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. code completion Area → source tooling: code completion source tooling Area: IDE support, SourceKit, and other source tooling
Projects
None yet
Development

No branches or pull requests

2 participants