Skip to content

Commit 8400b43

Browse files
committed
Sema: Don't diagnose thrown error type that contains errors
If we have error types here, type resolution already diagnosed an error; don't diagnose again.
1 parent 92d8bf7 commit 8400b43

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2545,7 +2545,7 @@ InterfaceTypeRequest::evaluate(Evaluator &eval, ValueDecl *D) const {
25452545
if (thrownTy) {
25462546
thrownTy = AFD->getThrownInterfaceType();
25472547
ProtocolDecl *errorProto = Context.getErrorDecl();
2548-
if (thrownTy && errorProto) {
2548+
if (thrownTy && !thrownTy->hasError() && errorProto) {
25492549
Type thrownTyInContext = AFD->mapTypeIntoContext(thrownTy);
25502550
if (!checkConformance(thrownTyInContext, errorProto)) {
25512551
SourceLoc loc;

test/decl/func/typed_throws.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// RUN: %target-typecheck-verify-swift -swift-version 5 -module-name test
22

3+
// Don't complain about <<error type>> not conforming to Error
4+
func invalidThrownType() throws(DoesNotExist) {}
5+
// expected-error@-1 {{cannot find type 'DoesNotExist' in scope}}
6+
37
// expected-note@+1{{type declared here}}
48
enum MyError: Error {
59
case fail

0 commit comments

Comments
 (0)