File tree Expand file tree Collapse file tree 2 files changed +28
-5
lines changed
validation-test/execution Expand file tree Collapse file tree 2 files changed +28
-5
lines changed Original file line number Diff line number Diff line change @@ -1809,14 +1809,20 @@ bool ExtensionDecl::isWrittenWithConstraints() const {
18091809 typeSig->getRequirementsWithInverses (typeReqs, typeInverseReqs);
18101810
18111811 // If the (non-inverse) requirements are different between the extension and
1812- // the original type, it's written with constraints. Note that
1813- // the extension can only add requirements, so we need only check the size
1814- // (not the specific requirements).
1815- if (extReqs.size () > typeReqs.size ()) {
1812+ // the original type, it's written with constraints.
1813+ if (extReqs.size () != typeReqs.size ()) {
18161814 return true ;
18171815 }
18181816
1819- assert (extReqs.size () == typeReqs.size ());
1817+ // In case of equal number of constraints, we have to check the specific
1818+ // requirements. Extensions can end up with fewer requirements than the type
1819+ // extended, due to a same-type requirement in the extension.
1820+ //
1821+ // This mirrors the 'same' check in `ASTMangler::gatherGenericSignatureParts`
1822+ for (size_t i = 0 ; i < extReqs.size (); i++) {
1823+ if (extReqs[i] != typeReqs[i])
1824+ return true ;
1825+ }
18201826
18211827 // If the type has no inverse requirements, there are no extra constraints
18221828 // to write.
Original file line number Diff line number Diff line change 1+ // RUN: %target-swift-frontend -interpret %s
2+ // REQUIRES: executable_test
3+
4+ // This only reproduced if you provide the -interpret flag!
5+ // https://github.com/apple/swift/issues/72719
6+
7+ protocol D { }
8+ struct U : D , Equatable { }
9+ class Q < T> { }
10+ class R < V, E: D & Equatable > { }
11+ extension R where E == U {
12+ struct S < X> { }
13+ static func a< T> ( _: T ) -> R {
14+ let x = Q < S < T > > ( )
15+ fatalError ( )
16+ }
17+ }
You can’t perform that action at this time.
0 commit comments