Transitively inferring a protocol type binding from a contextual
type means that the binding set for a leading-dot member reference
is complete because there could be no other sources of bindings
when expression is connected directly to a contextual type.
Resolves: rdar://145103149
Propagate fully or partially resolved contextual type down into
the body of result builder transformed closure by eagerly binding
intermediate body result type to the contextual one. This helps to
determine when closure body could be solved early.
Resolves: rdar://106364495
In cases like:
```
if (...) {
<body>
} else if (...) {
<body>
} else if (...) {
<body>
}
```
Each branch should end with `buildOptional` wrapping `buildEither`
because there is no covering unconditional `else` in the sequence:
```
var $__builder: <<Type>>
if (...) {
$__builder = buildOptional(.some(buildEither(...)))
} else {
if (...) {
$__builder = buildOptional(.some(buildEither(...)))
} else {
if (...) {
$__builder = buildOptional(.some(buildEither(...)))
} else {
$__builder = buildOptional(.none)
}
}
}
```
Resolves: rdar://104345754
Fixes a bug in `buildOptional` injection for `if else` branches
without unconditional `else` which leaves type-join with just `.some(...)`
and results in optionality mismatch if `buildOptional` don't not produce
an optional type.
Leading-dot syntax allows implicitly unwrapping result type to form
a base type of the call, `getOpenedResultBuilderTypeFor` needs to
account for that.
Resolves: https://github.com/apple/swift/issues/60586
A call to `.callAsFunction` could be injected after initializer if the type is
callable, `getCalleeLocator` should recognize that situation and return
appropriate locator otherwise if `callAsFunction` has e.g. a result builder
attached to one of its parameters the solver wouldn't be able to find it.
Resolves: rdar://92914226
Enables SE-0348 `buildPartialBlock` feature by default. The frontend flag is kept for compatibility with existing clients, but is now ineffective.
Also includes some improved error messages for invalid result builder call sites.
Augment the constraint solver to fallback to implicit `~=` application
when member couldn't be found for `EnumElement` patterns because
`case` statement should be able to match enum member directly, as well
as through an implicit `~=` operator application.
Workaround for Clang enum typaliases called `isInvalid()` and `getInterfaceType()`
on discovered declarations. That doesn't play well with result builders because
declarations/patterns used in the body of a result builder don't get a type until
a solution is applied. Calling `isInvalid()` or `getInterfaceType` on declarations
located in the body of a result builder trigger a separate type-check for the
declaration that interferes with builder transformation and leads to crashes.