File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed
test/decl/protocol/conforms
validation-test/compiler_crashers_2_fixed Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -545,6 +545,14 @@ swift::matchWitness(
545
545
// Result types must match.
546
546
// FIXME: Could allow (trivial?) subtyping here.
547
547
if (!ignoreReturnType) {
548
+ if (reqResultType->hasDynamicSelfType ()) {
549
+ auto classDecl = witness->getDeclContext ()->getSelfClassDecl ();
550
+ if (!classDecl || classDecl->isFinal () ||
551
+ witnessResultType->hasDynamicSelfType ())
552
+ reqResultType = reqResultType->eraseDynamicSelfType ();
553
+ witnessResultType = witnessResultType->eraseDynamicSelfType ();
554
+ }
555
+
548
556
auto reqTypeIsIUO =
549
557
req->getAttrs ().hasAttribute <ImplicitlyUnwrappedOptionalAttr>();
550
558
auto witnessTypeIsIUO =
Original file line number Diff line number Diff line change @@ -86,3 +86,29 @@ extension Node {
86
86
}
87
87
88
88
class IntNode : Node { }
89
+
90
+ // SR-8902
91
+ protocol P8902 {
92
+ associatedtype A // expected-note {{protocol requires nested type 'A'; do you want to add it?}}
93
+ func f( _ x: A ) -> Self
94
+ }
95
+ struct S : P8902 {
96
+ func f( _ x: Bool ) -> S { fatalError ( ) }
97
+ }
98
+ class C8902 : P8902 { // expected-error {{type 'C8902' does not conform to protocol 'P8902'}}
99
+ func f( _ x: Bool ) -> C8902 { fatalError ( ) }
100
+ }
101
+ final class C8902b : P8902 {
102
+ func f( _ x: Bool ) -> C8902b { fatalError ( ) }
103
+ }
104
+ class C8902c : P8902 {
105
+ func f( _ x: Bool ) -> Self { fatalError ( ) }
106
+ }
107
+ protocol P8902complex {
108
+ associatedtype A
109
+ func f( ) -> ( A , Self ? )
110
+ }
111
+ final class C8902complex : P8902complex {
112
+ func f( ) -> ( Bool , C8902complex ? ) { fatalError ( ) }
113
+ }
114
+
Original file line number Diff line number Diff line change 1
- // RUN: not %target-swift-frontend %s -emit-ir
1
+ // RUN: %target-swift-frontend %s -emit-ir
2
2
3
3
4
4
public protocol E {
You can’t perform that action at this time.
0 commit comments