Skip to content

Commit 091fa17

Browse files
Suyash SrijanSuyash Srijan
authored andcommitted
[typechecker] don't check for error conformance until we know we're casting from Error
1 parent ef6a741 commit 091fa17

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4041,11 +4041,11 @@ CheckedCastKind TypeChecker::typeCheckCheckedCast(Type fromType,
40414041
// }
40424042
// }
40434043
auto exceptionType = getExceptionType(dc, SourceLoc());
4044-
auto toTypeConformsToError =
4045-
conformsToProtocol(toType, Context.getErrorDecl(), dc,
4046-
ConformanceCheckFlags::InExpression);
4047-
if (fromType->isEqual(exceptionType) && !toTypeConformsToError) {
4048-
return failed();
4044+
if (fromType->isEqual(exceptionType)) {
4045+
if (!conformsToProtocol(toType, Context.getErrorDecl(), dc,
4046+
ConformanceCheckFlags::InExpression)) {
4047+
return failed();
4048+
}
40494049
}
40504050

40514051
bool toRequiresClass;

0 commit comments

Comments
 (0)