Skip to content

Commit 05fc089

Browse files
committed
[Generic Signature Builder] Sort invalid source locations properly.
Fixes SR-9496 / rdar://problem/46699008.
1 parent d2ddbc8 commit 05fc089

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6831,6 +6831,14 @@ void GenericSignatureBuilder::checkSameTypeConstraints(
68316831
auto locA = (*a)->constraint.source->getLoc();
68326832
auto locB = (*b)->constraint.source->getLoc();
68336833

6834+
// Put invalid locations after valid ones.
6835+
if (locA.isInvalid() || locB.isInvalid()) {
6836+
if (locA.isInvalid() != locB.isInvalid())
6837+
return locA.isInvalid() ? 1 : -1;
6838+
6839+
return 0;
6840+
}
6841+
68346842
auto bufferA = sourceMgr.findBufferContainingLoc(locA);
68356843
auto bufferB = sourceMgr.findBufferContainingLoc(locB);
68366844

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %target-swift-frontend -typecheck %s
2+
3+
protocol P1 {
4+
associatedtype A1
5+
}
6+
7+
protocol P2 {
8+
associatedtype A2
9+
}
10+
11+
struct S1<G1: P1, G2: P1>: P1 where G1.A1 == G2.A1 {
12+
typealias A1 = G1.A1
13+
}
14+
15+
struct S2<G1: P1, G2: P2>: P2 where G1.A1 == G2.A2 {
16+
typealias A2 = G2.A2
17+
}
18+
19+
struct S3<G1: P1, G2: P2> where G1.A1 == G2.A2 {
20+
func f<G: P1>(_: G) -> S3<S1<G, G1>, S2<G, G2>> {
21+
fatalError()
22+
}
23+
}

0 commit comments

Comments
 (0)