Instead of diagnosing in CSApply, let's create a
fix and diagnose in the solver instead.
Additionally, make sure we assign ErrorTypes to
any VarDecls bound by the invalid pattern, which
fixes a crash.
rdar://110638279
Opened existentials should be erased to the dependent upper bound
if the dependent member can be reduced to a concrete type. This
allows the generic signature to support parameterized protocol types
and bound generic class types by producing a more specific constraint
instead of just a plain protocol or class.
Returning `true` is wrong here as we could have
the error diagnosed by another fix, which if not
handled, would lead to us crashing as we assume
we diagnosed the issue. Instead, return `false`,
allowing us to at least bail with a bad error
rather than a crash.
We still need to go through and update argument
list diagnostic logic to handle patterns, but I'm
leaving that as future work for now.
rdar://107724970
rdar://107651291
For example @objc lookup could find multiple instance members
on `AnyObject`. It should be allowed to diagnose issues with
that as non-ambiguous if all fixes have the same kind/base type.
Resolves: rdar://102412006
Previous implementation blindly took the first solution
and tried to diagnose, but that's not a safe assumption.
It's possible that among the solution-fix pairs, one
of `noncopyableTy`'s within the fix differs from the
others. Things probably can go wrong because the solution
doesn't correspond to that type.
Also, in that case we'd be emitting a diagnostic that
may not make any sense. In such cases, now we decline
to emit a diagnostic.
Thanks Pavel for catching this.
Since values of generic type are currently assumed to always
support copying, we need to prevent move-only types from
being substituted for generic type parameters.
This approach leans on a `_Copyable` marker protocol to which
all generic type parameters implicitly must conform.
A few other changes in this initial implementation:
- Now every concrete type that can conform to Copyable will do so. This fixes issues with conforming to a protocol that requires Copyable.
- Narrowly ban writing a concrete type `[T]` when `T` is move-only.
associated failure diagnostic.
This constraint fix is unused now that MacroExpansionExpr always has an
argument list, and goes through the AddMissingArguments constraint fix for
this error.
Instead of failing constraint generation by returning `nullptr` for an `ErrorExpr` or returning a null type when a type fails to be resolved, return a fresh type variable. This allows the constraint solver to continue further and produce more meaningful diagnostics.
Most importantly, it allows us to produce a solution where previously constraint generation for a syntactic element had failed, which is required to type check multi-statement closures in result builders inside the constraint system.