Files
swift-mirror/validation-test/IDE/issues_fixed/rdar120798355.swift
Alex Hoppen 09ae4f5d5d [CodeCompletion] Fix issue in which parts of a result builder were incorrectly skipped
`getLoc` does not necesarrily return the start location of the location (e.g. for `a.b().c()` it returns the location of `c` because that’s the location of the call). But we used the location from `getLoc` as the start location of the synthesized `buildExpression` call. In the added test case, this means that the `buildExpression` call only contained `everlay() {}` and not the code completion token. We thus infered that we could skip it the entire `MyStack {}.pnTabGesture {}.everlay() {}` call for code completion, which isn’t correct.

rdar://120798355
2024-01-12 15:03:57 -08:00

32 lines
659 B
Swift

// RUN: %batch-code-completion
func test() {
MyStack {
MyStack {
}
.pnTapGesture {
#^COMPLETE^#
}
.everlay() {
}
}
}
struct MyView {
func everlay(content: () -> Void) -> MyView { MyView() }
}
struct MyStack {
init(@WiewBuilder content: () -> MyView) {}
func pnTapGesture(perform action: () -> Void) -> MyView { MyView() }
}
@resultBuilder
struct WiewBuilder {
static func buildExpression(_ content: MyView) -> MyView { content }
static func buildBlock(_ content: MyView) -> MyView { content }
static func buildBlock() -> MyView { MyView() }
}
// COMPLETE: Decl[FreeFunction]/CurrModule: test()[#Void#]