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-14601] Code completion always ends up in the fallback case when completing inside result builders #56953

Closed
ahoppen opened this issue May 6, 2021 · 4 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

@ahoppen
Copy link
Contributor

ahoppen commented May 6, 2021

Previous ID SR-14601
Radar rdar://problem/77673447
Original Reporter @ahoppen
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s CodeCompletion
Labels Bug
Assignee @ahoppen
Priority Medium

md5: ff39bc29921815d28dc2ea00efd8f411

Issue Description:

When completing inside a result builder, AFAICT we are generating the constraint system directly from the result builder’s body without ever through typeCheckExpression. Because of this, we never call typeCheckForCodeCompletion during the initial type check here.

Thus, we don’t receive a sawSolution callback in the CodeCompletionCallbacks and end up in the fallback case here.

We should have a code completion hook inside the result builder transformer that calls the code completion callbacks appropriately, so we don’t end up in the fallback case.

To reproduce this, add a breakpoint (or fail otherwise) in DotExprTypeCheckCompletionCallback:: fallbackTypeCheck and run the following

$ cat ~/Desktop/test.swift
protocol MyView {
    associatedtype Body : MyView
    @MyViewBuilder var body: Self.Body { get }
}

@resultBuilder public struct MyViewBuilder {
    static func buildBlock() -> MyZStack<Never> { fatalError() }
    static func buildBlock<Content>(_ content: Content) -> Content { content }
}

struct MyAlignment {
  static let center: MyAlignment
}

struct BottomMenu: MyView {
    var body: some MyView {
        let a = MyAlignment.#^COMPLETE^#
    }
}
$ ./swift-ide-test -code-completion -code-completion-token=COMPLETE -source-filename ~/Desktop/test.swift
@ahoppen
Copy link
Contributor Author

ahoppen commented May 6, 2021

@swift-ci create

@ahoppen
Copy link
Contributor Author

ahoppen commented May 6, 2021

@swift-ci Create

@ahoppen
Copy link
Contributor Author

ahoppen commented May 7, 2021

@swift-ci create

@ahoppen
Copy link
Contributor Author

ahoppen commented Apr 4, 2022

Fixed by #41846

@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