Skip to content

Add support for inferring generic arguments of result builder attributes#86209

Draft
calda wants to merge 12 commits intoswiftlang:mainfrom
calda:cal--infer-result-builder-generics
Draft

Add support for inferring generic arguments of result builder attributes#86209
calda wants to merge 12 commits intoswiftlang:mainfrom
calda:cal--infer-result-builder-generics

Conversation

@calda
Copy link
Copy Markdown
Contributor

@calda calda commented Dec 25, 2025

Swift evolution proposal: swiftlang/swift-evolution#3062


This PR adds support for inferring generic arguments of result builder attributes from the return type of the attached declaration.

For example, this sample code was previously rejected with the error "reference to generic type 'ArrayBuilder' requires arguments in <...>", but it now compiles successfully by inferring it as ArrayBuilder<String>.

@resultBuilder
struct ArrayBuilder<Element> {
  static func buildBlock(_ elements: Element...) -> [Element] {
    elements
  }
}

@ArrayBuilder
var stringArray: [String] {
  "foo"
  "bar"
}

@calda calda force-pushed the cal--infer-result-builder-generics branch 6 times, most recently from 7d28973 to bb0a46e Compare December 26, 2025 20:19
@calda calda changed the title Add support for inferring generic parameters of result builder attributes Add support for inferring generic arguments of result builder attributes Jan 3, 2026
@calda calda force-pushed the cal--infer-result-builder-generics branch 2 times, most recently from 51361df to 05f7fef Compare January 4, 2026 16:26
@calda calda force-pushed the cal--infer-result-builder-generics branch from aa4e732 to 7f637ca Compare March 13, 2026 13:56
@calda calda force-pushed the cal--infer-result-builder-generics branch from 5266f5f to 76cd5fd Compare March 13, 2026 15:45
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

Successfully merging this pull request may close these issues.

1 participant