Rather than mutating the parameter pattern in place and separately
return whether an error occurred, return the new pattern or NULL if an
error occurred. While here, switch over to ContextualPattern for the
input.
And get rid of that infernal "goto".
Contextual pattern describes a particular pattern with enough
contextual information to determine its type. Use this to simplify
TypeChecker::typeCheckPattern()'s interface in a manner that will
admit request'ification.
Make TypeChecker::typeCheckPattern() return the computed type, rather
than returning an "error" flag. More importantly, make it functional,
so that it doesn't set the type it computes on the pattern.
Use UnresolvedType as a placeholder for types that need to be
inferred, rather than a null type. This allows us to produce
structural types involving types that need to be inferred.
Note that with this change as-is, we get a number of duplicated
diagnostics, because typeCheckPattern() will be called multiple times
for the same pattern and will emit some diagnostics each time. This
will be addressed in a subsequent commit.
Curry thunks create AutoClosureExprs with parameters, and we can't just
fold those away.
Also, remove an older AutoClosureExpr cleanup that seems to be
redundant.
It might be either impossible to infer the base because there is
no contextual information e.g. `_ = .foo` or there is something
else wrong in the expression which disconnects member reference
from its context.
Rather than setting up the constraint solver with a single expression
(that gets recorded for parents/depths), record each expression that
goes through constraint generation.
This commit moves the getNSObjectType and
getObjCSelectorType methods from TypeChecker
onto ASTContext. In addition, it moves the
FOR_KNOWN_FOUNDATION_TYPES macro into a separate
file to define each of the Obj-C type decls
we want to have access to.
ProtocolConformanceRef already has an invalid state. Drop all of the
uses of Optional<ProtocolConformanceRef> and just use
ProtocolConformanceRef::forInvalid() to represent it. Mechanically
translate all of the callers and callsites to use this new
representation.
TypeCheckPattern used to splat the interface type into this, and
different parts of the compiler would check one or the other. There is
now one source of truth: The interface type. The type repr is now just
a signal that the user has written an explicit type annotation on
a parameter. For variables, we will eventually be able to just grab
this information from the parent pattern.