Skip to content

Commit 0023695

Browse files
committed
[NFC] Update calls to assume resolveType never returns null
1 parent 6ab29cb commit 0023695

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

lib/Sema/CSGen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,7 @@ namespace {
14991499
options |= TypeResolutionFlags::AllowUnboundGenerics;
15001500
auto result = TypeResolution::forContextual(CS.DC, options)
15011501
.resolveType(repr);
1502-
if (!result || result->hasError()) {
1502+
if (result->hasError()) {
15031503
return Type();
15041504
}
15051505
return result;
@@ -2771,7 +2771,7 @@ namespace {
27712771
Type castType = TypeResolution::forContextual(
27722772
CS.DC, TypeResolverContext::InExpression)
27732773
.resolveType(isp->getCastTypeRepr());
2774-
if (!castType) {
2774+
if (castType->hasError()) {
27752775
return false;
27762776
}
27772777

lib/Sema/TypeCheckAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2853,7 +2853,7 @@ void AttributeChecker::visitImplementsAttr(ImplementsAttr *attr) {
28532853
}
28542854

28552855
// Definite error-types were already diagnosed in resolveType.
2856-
if (!T || T->hasError())
2856+
if (T->hasError())
28572857
return;
28582858
attr->setProtocolType(T);
28592859

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,7 @@ TypeExpr *PreCheckExpression::simplifyNestedTypeExpr(UnresolvedDotExpr *UDE) {
13971397
auto resolution = TypeResolution::forContextual(DC, options);
13981398
auto BaseTy = resolution.resolveType(InnerTypeRepr);
13991399

1400-
if (BaseTy && BaseTy->mayHaveMembers()) {
1400+
if (BaseTy->mayHaveMembers()) {
14011401
auto lookupOptions = defaultMemberLookupOptions;
14021402
if (isa<AbstractFunctionDecl>(DC) ||
14031403
isa<AbstractClosureExpr>(DC))

lib/Sema/TypeCheckPattern.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ static Type validateTypedPattern(TypedPattern *TP, TypeResolution resolution) {
705705
}
706706

707707
auto ty = resolution.resolveType(Repr);
708-
if (!ty || ty->hasError()) {
708+
if (ty->hasError()) {
709709
return ErrorType::get(Context);
710710
}
711711

@@ -1233,7 +1233,7 @@ Pattern *TypeChecker::coercePatternToType(ContextualPattern pattern,
12331233
TypeResolutionOptions paramOptions(TypeResolverContext::InExpression);
12341234
auto castType = TypeResolution::forContextual(dc, paramOptions)
12351235
.resolveType(IP->getCastTypeRepr());
1236-
if (!castType || castType->hasError())
1236+
if (castType->hasError())
12371237
return nullptr;
12381238
IP->setCastType(castType);
12391239

lib/Sema/TypeCheckType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ static Type applyGenericArguments(Type type, TypeResolution resolution,
746746
if (nominal->isOptionalDecl()) {
747747
// Validate the generic argument.
748748
Type objectType = resolution.resolveType(genericArgs[0]);
749-
if (!objectType || objectType->hasError()) {
749+
if (objectType->hasError()) {
750750
return ErrorType::get(ctx);
751751
}
752752

lib/Sema/TypeCheckType.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ class TypeResolution {
366366
///
367367
/// \param TyR The type representation to check.
368368
///
369-
/// \returns a well-formed type or an ErrorType in case of an error.
369+
/// \returns A well-formed type that is never null, or an \c ErrorType in case of an error.
370370
Type resolveType(TypeRepr *TyR);
371371

372372
/// Whether this type resolution uses archetypes (vs. generic parameters).

0 commit comments

Comments
 (0)