Skip to content

Commit fb5e356

Browse files
committed
[Sema] Remove a couple other uses of hasError and hasUnresolvedType
These cases should no longer be reachable.
1 parent 2c0ea13 commit fb5e356

File tree

2 files changed

+6
-40
lines changed

2 files changed

+6
-40
lines changed

lib/Sema/SyntacticElementTarget.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,6 @@ SyntacticElementTarget::SyntacticElementTarget(
3636
assert((!contextualInfo.getType() || contextualPurpose != CTP_Unused) &&
3737
"Purpose for conversion type was not specified");
3838

39-
// Take a look at the conversion type to check to make sure it is sensible.
40-
if (auto type = contextualInfo.getType()) {
41-
// If we're asked to convert to an UnresolvedType, then ignore the request.
42-
// This happens when CSDiags nukes a type.
43-
if (type->is<UnresolvedType>() ||
44-
(type->is<MetatypeType>() && type->hasUnresolvedType())) {
45-
contextualInfo.typeLoc = TypeLoc();
46-
contextualPurpose = CTP_Unused;
47-
}
48-
}
49-
5039
kind = Kind::expression;
5140
expression.expression = expr;
5241
expression.dc = dc;

lib/Sema/TypeCheckPattern.cpp

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,41 +1736,18 @@ Pattern *TypeChecker::coercePatternToType(
17361736
/// contextual type.
17371737
void TypeChecker::coerceParameterListToType(ParameterList *P,
17381738
AnyFunctionType *FN) {
1739-
1740-
// Local function to check if the given type is valid e.g. doesn't have
1741-
// errors, type variables or unresolved types related to it.
1742-
auto isValidType = [](Type type) -> bool {
1743-
return !(type->hasError() || type->hasUnresolvedType());
1744-
};
1745-
1746-
// Local function to check whether type of given parameter
1747-
// should be coerced to a given contextual type or not.
1748-
auto shouldOverwriteParam = [&](ParamDecl *param) -> bool {
1749-
return !isValidType(param->getTypeInContext());
1750-
};
1751-
1752-
auto handleParameter = [&](ParamDecl *param, Type ty, bool forceMutable) {
1753-
if (forceMutable)
1754-
param->setSpecifier(ParamDecl::Specifier::InOut);
1755-
1756-
// If contextual type is invalid and we have a valid argument type
1757-
// trying to coerce argument to contextual type would mean erasing
1758-
// valuable diagnostic information.
1759-
if (isValidType(ty) || shouldOverwriteParam(param)) {
1760-
param->setInterfaceType(ty->mapTypeOutOfContext());
1761-
}
1762-
};
1763-
17641739
// Coerce each parameter to the respective type.
17651740
ArrayRef<AnyFunctionType::Param> params = FN->getParams();
17661741
for (unsigned i = 0, e = P->size(); i != e; ++i) {
17671742
auto &param = P->get(i);
17681743
assert(param->getArgumentName().empty() &&
17691744
"Closures cannot have API names");
1770-
1771-
handleParameter(param,
1772-
params[i].getParameterType(),
1773-
params[i].isInOut());
17741745
assert(!param->isDefaultArgument() && "Closures cannot have default args");
1746+
1747+
if (params[i].isInOut())
1748+
param->setSpecifier(ParamDecl::Specifier::InOut);
1749+
1750+
param->setInterfaceType(
1751+
params[i].getParameterType()->mapTypeOutOfContext());
17751752
}
17761753
}

0 commit comments

Comments
 (0)