Skip to content

Commit 83b3fcb

Browse files
DougGregorslavapestov
authored andcommitted
[Generic Signature Builder] Sort invalid source locations properly.
Fixes SR-9496 / rdar://problem/46699008.
1 parent 8012d0f commit 83b3fcb

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
@@ -6837,6 +6837,14 @@ void GenericSignatureBuilder::checkSameTypeConstraints(
68376837
auto locA = (*a)->constraint.source->getLoc();
68386838
auto locB = (*b)->constraint.source->getLoc();
68396839

6840+
// Put invalid locations after valid ones.
6841+
if (locA.isInvalid() || locB.isInvalid()) {
6842+
if (locA.isInvalid() != locB.isInvalid())
6843+
return locA.isInvalid() ? 1 : -1;
6844+
6845+
return 0;
6846+
}
6847+
68406848
auto bufferA = sourceMgr.findBufferContainingLoc(locA);
68416849
auto bufferB = sourceMgr.findBufferContainingLoc(locB);
68426850

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)