Skip to content

Commit 2d76c38

Browse files
authored
Merge pull request #80965 from slavapestov/fix-rdar149438520-6.2
[6.2] Sema: Fix case where witness thrown error type is a subtype of a type parameter
2 parents 7f0d24b + dc70a0e commit 2d76c38

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -912,8 +912,7 @@ RequirementMatch swift::matchWitness(
912912

913913
case ThrownErrorSubtyping::Subtype:
914914
// If there were no type parameters, we're done.
915-
if (!reqThrownError->hasTypeVariable() &&
916-
!reqThrownError->hasTypeParameter())
915+
if (!reqThrownError->hasTypeParameter())
917916
break;
918917

919918
LLVM_FALLTHROUGH;

test/decl/protocol/conforms/typed_throws.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,17 @@ public protocol HasRethrowingMap: Sequence {
7777
}
7878

7979
extension Array: HasRethrowingMap {}
80+
81+
// rdar://149438520 -- incorrect handling of subtype relation between type parameter and Never
82+
protocol DependentThrowing {
83+
associatedtype E: Error
84+
func f() throws(E)
85+
}
86+
87+
extension DependentThrowing {
88+
func f() {}
89+
}
90+
91+
struct DefaultDependentThrowing: DependentThrowing {
92+
typealias E = Error
93+
}

0 commit comments

Comments
 (0)