Skip to content

Commit 42a24eb

Browse files
committed
Use hasDynamicSelfType and add another test where the result type is complex and includes the non-dynamic self.
1 parent 762abf2 commit 42a24eb

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,9 +545,10 @@ swift::matchWitness(
545545
// Result types must match.
546546
// FIXME: Could allow (trivial?) subtyping here.
547547
if (!ignoreReturnType) {
548-
if (reqResultType->is<DynamicSelfType>()) {
548+
if (reqResultType->hasDynamicSelfType()) {
549549
auto classDecl = witness->getDeclContext()->getSelfClassDecl();
550-
if (!classDecl || classDecl->isFinal() || witnessResultType->is<DynamicSelfType>())
550+
if (!classDecl || classDecl->isFinal() ||
551+
witnessResultType->hasDynamicSelfType())
551552
reqResultType = reqResultType->eraseDynamicSelfType();
552553
witnessResultType = witnessResultType->eraseDynamicSelfType();
553554
}

test/decl/protocol/conforms/self.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,11 @@ final class C8902b : P8902 {
104104
class C8902c : P8902 {
105105
func f(_ x: Bool) -> Self { fatalError() }
106106
}
107+
protocol P8902complex {
108+
associatedtype A
109+
func f() -> (A, Self?)
110+
}
111+
final class C8902complex : P8902complex {
112+
func f() -> (Bool, C8902complex?) { fatalError() }
113+
}
107114

0 commit comments

Comments
 (0)