[Accepted] SE-0326: Multi-statement closure parameter/result type inference

Hello Swift Community,

The review of SE-0326: Multi-statement closure parameter/result type inference has completed. Feedback was light but positive, and the core team has accepted this proposal.

The core team recognizes that the language change has the slight possibility of requiring source changes, but that the benefits brought by this change merit including it without waiting for a language variant. In a test on a very large corpus of Swift source, only 1 instance of source code needing to be updated was found. The team would be interested in any feedback regarding more frequent source breaks from this change during release convergence.

Thank you to everyone who participated in the review!

Ben Cohen
Review Manager


Is there any data on how removal of the explicit signature affects performance of closure type-checking?

Type-checking SwiftUI code is an existing pain point for us. We use -warn-long-expression-type-checking=1000 + -warnings-as-errors to prevent developers from creating loo large SwiftUI expressions, but due to the non-deterministic nature of the warning, even if it compiles normally on local machine, it may randomly fail on CI or on someone else's machine.

It shouldn't affect type-checking time for the multi-statement closures significantly by itself but there is a possibility that removal of the type could affect some of the "complex" expressions that are replying on explicit parameter types to be solved efficiently. Also note that these changes do not affect type-checking of SwiftUI bodies because such bodies have special type-checking semantics.

Is this SwiftUI-specific, or does it apply to result builders in general?

Result builders in general. This proposal does not affect result builders, because they are already type checked as a "single expression" in the constraint system. However, the implementation of SE-0326 introduces a new incremental statement type checking mechanism that we hope improves the performance of type checking result builders once they're ported to the new infrastructure.


Sorry for the confusion, I should have mentioned that it's result builders in general and not just SwiftUI.


What is the status of this feature? I don't see it in version 5.6 or 5.7 sections in the CHANGELOG

1 Like

The feature is available under the flag still. There are some performance problems related to operator chaining that need to be addressed before it could be enabled by default.