Skip to content

Commit ef6a741

Browse files
Suyash SrijanSuyash Srijan
authored andcommitted
[typechecker] remove protocol conformance diagnostic when type does not conform to Error when using is pattern in catch statement
1 parent 0ee0084 commit ef6a741

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4045,7 +4045,6 @@ CheckedCastKind TypeChecker::typeCheckCheckedCast(Type fromType,
40454045
conformsToProtocol(toType, Context.getErrorDecl(), dc,
40464046
ConformanceCheckFlags::InExpression);
40474047
if (fromType->isEqual(exceptionType) && !toTypeConformsToError) {
4048-
diagnose(diagLoc, diag::type_does_not_conform, toType, exceptionType);
40494048
return failed();
40504049
}
40514050

test/stmt/errors.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ struct SR_6400_S_2: Error {}
178178
func sr_6400() throws {
179179
do {
180180
throw SR_6400_E.castError
181-
} catch is SR_6400_S_1 { // expected-error {{type 'SR_6400_S_1' does not conform to protocol 'Error'}} expected-warning {{cast from 'Error' to unrelated type 'SR_6400_S_1' always fails}}
181+
} catch is SR_6400_S_1 { // expected-warning {{cast from 'Error' to unrelated type 'SR_6400_S_1' always fails}}
182182
print("Caught error")
183183
}
184184

0 commit comments

Comments
 (0)