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-14244] Tuple containing one or more closures is expanded incorrectly in source editor #60693

Open
swift-ci opened this issue Feb 17, 2021 · 1 comment

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-14244
Radar rdar://problem/74617017
Original Reporter orchetect (JIRA User)
Type Bug

Attachment: Download

Environment

Xcode 12.5 beta (12E5220o), Swift 5.3/5.4

Additional Detail from JIRA
Votes 0
Component/s CodeCompletion, SourceKit-LSP
Labels Bug, Parser, TypeChecker
Assignee None
Priority Medium

md5: 7b3e32b05c391b343b357d6ddce792e5

Issue Description:

Observed Behavior: When a function parameter is a tuple containing one or more closure signatures, pressing Return while its placeholder is highlighted in Xcode's source editor produces incorrect code template expansion. All other parameters in the tuple are ignored. If the closure signatures have an empty (()) input pattern, then only the first closure found is expanded. If the the closures expect an input value, then those input values are erroneously aggregated and applied to a single expanded closure.

Expected behavior: The expansion should expand the tuple's signature completely, and for any closures it encounters it should produce fully labelled and parameterized closure structures.

Example 1:

func someMethod(closures: (closure1: () -> Void,
                           closure2: () -> Void)) { }

incorrectly expands as:

someMethod {
    <#code#>
}

but should expand as:

someMethod(closures: (closure1: {
    <#code#>
}, closure2: {
    <#code#>
}))

Example 2:

func someMethod(closures: (int: Int,
                           closure1: (Double) -> Data,
                           closure2: (String, Int) -> Float32)) { }

incorrectly expands as:

someMethod { (<#Double#>, <#String#>, <#Int#>) -> Float32 in
    <#code#>
}

but should expand as:

someMethod(closures: (int: <#Int#>, closure1: { (<#Double#>) -> Data in
    <#code#>
}, closure2: { (<#String#>, <#Int#>) -> Float32 in
    <#code#>
}))
@typesanitizer
Copy link

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 2022
@ahoppen ahoppen removed the bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. label Aug 22, 2022
@ahoppen ahoppen transferred this issue from apple/sourcekit-lsp Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants