[Sema] Use a TypeLoc for conversions with contextual types.

With a TypeLoc, we have a chance to offer diagnostics or even fix-its
to the contextual type, even though it's not represented by an
expression in the constraint system. This commit mostly just passes it
through, without attempting to use it anywhere or even pass a real
TypeLoc (with a valid TypeRepr).

(It does drop the contextual type parameter from
typeCheckExpressionShallow, since there were zero callers using it.)

No functionality change...yet.
This commit is contained in:
Jordan Rose
2016-04-20 17:33:39 -07:00
parent 7ad6a8bd61
commit 16f857c78c
8 changed files with 69 additions and 66 deletions

View File

@@ -3173,10 +3173,10 @@ ConstraintSystem::simplifyMemberConstraint(const Constraint &constraint) {
// Determine whether or not we want to provide an optional chaining fixit or
// a force unwrap fixit.
bool optionalChain;
if (!contextualType)
if (!getContextualType())
optionalChain = !(Options & ConstraintSystemFlags::PreferForceUnwrapToOptional);
else
optionalChain = !contextualType->getOptionalObjectType().isNull();
optionalChain = !getContextualType()->getOptionalObjectType().isNull();
auto fixKind = optionalChain ? FixKind::OptionalChaining : FixKind::ForceOptional;
// Note the fix.
@@ -3206,10 +3206,10 @@ ConstraintSystem::simplifyMemberConstraint(const Constraint &constraint) {
// Determine whether or not we want to provide an optional chaining fixit or
// a force unwrap fixit.
bool optionalChain;
if (!contextualType)
if (!getContextualType())
optionalChain = !(Options & ConstraintSystemFlags::PreferForceUnwrapToOptional);
else
optionalChain = !contextualType->getOptionalObjectType().isNull();
optionalChain = !getContextualType()->getOptionalObjectType().isNull();
auto fixKind = optionalChain ? FixKind::OptionalChaining : FixKind::ForceOptional;
// Note the fix.