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-2750] No code hint when using 'Then' in class scope #45354

Closed
swift-ci opened this issue Sep 24, 2016 · 12 comments
Closed

[SR-2750] No code hint when using 'Then' in class scope #45354

swift-ci opened this issue Sep 24, 2016 · 12 comments
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

@swift-ci
Copy link
Collaborator

Previous ID SR-2750
Radar rdar://problem/36384704
Original Reporter devxoul (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 16
Component/s CodeCompletion
Labels Bug
Assignee None
Priority Medium

md5: a8b1807307362d9e9f0f4df3d9f5d0e5

Issue Description:

xHello, I'm the author of the library Then. While using it, Xcode doesn't give any code hint in class scope. I attached the screen capture for understanding.

How to re-produce the bug

1. Open any .swift file. You can reproduce with Playground, too.
2. Copy and paste the source code of Then: https://github.com/devxoul/Then/blob/master/Sources/Then.swift
3. Declare a class, and define a property using Then.

Class Scope

class ViewControlller: UIViewController {
  let myView = UIView().then {
    $0. // This doesn't give any code hints
  }
}

File Scope

let myView = UIView().then {
  $0. // This does give code hints properly
}
@swift-ci
Copy link
Collaborator Author

Comment by Hannes Oud (JIRA)

I created another issue with more cases of where it works and where it doesn't: https://bugs.swift.org/browse/SR-5051

@belkadan
Copy link
Contributor

belkadan commented Jan 9, 2018

@swift-ci create

@nkcsgexi
Copy link
Member

I cannot reproduce by Xcode 9B37. hannesoid (JIRA User), could you verify in the latest version of Xcode 9.1 beta and see if the issue reproduces? If it does, please attach the entire reproducing code base, since the root cause can be in the broader context.

@acecilia
Copy link

@nkcsgexi hannesoid (JIRA User) It may be already fixed. Take a look at the bottom of: devxoul/Then#14

@nkcsgexi
Copy link
Member

ok, mark this as resolved for now.

@swift-ci
Copy link
Collaborator Author

Comment by Suyeol Jeon (JIRA)

@nkcsgexi I've found an interesting thing. It works without a type annotation and it doesn't work with a type annotation(: UILabel).

Without type annotation

With type annotation

@nkcsgexi
Copy link
Member

I can reproduce this issue. Simplified test case:

We don't have code completion at <HERE>:

public protocol Then {}
extension Then {
  public func then(_ block: (Self) throws -> Void) rethrows -> Self {
    return self
  }
}
class C: Then {
  init() {}
  func foo() {}
}
class D {
  let myView: C = C().then { $0.#HERE# }
}

@swift-ci
Copy link
Collaborator Author

Comment by Austin Rude (JIRA)

Just wanted to mention I get completions for `let` variables, but not for `lazy var` using Then.

When this is worked on can we test that too - I didn't see it mentioned in either bug.

@rintaro
Copy link
Mannequin

rintaro mannequin commented Mar 18, 2019

I believe #22957 fixes this.

@swift-ci
Copy link
Collaborator Author

Comment by doom (JIRA)

this bug reproduce in Xcode 10.2.

devxoul/Then#67

@belkadan
Copy link
Contributor

Yes, that fix did not make it into Swift 5.

@AnnaZaks
Copy link
Mannequin

AnnaZaks mannequin commented Aug 9, 2019

devxoul (JIRA User), Could you verify if the problem is fixed in the latest Xcode betas 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

5 participants