Skip to content

Commit 7cc8063

Browse files
committed
SIL: Forgot to pass SubstFlags::PreservePackExpansionLevel in one place
1 parent 36b3d3a commit 7cc8063

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

lib/SIL/IR/SILTypeSubstitution.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ class SILTypeSubstituter :
7777
ProtocolConformanceRef(conformedProtocol),
7878
conformingReplacementType->getCanonicalType(),
7979
typeExpansionContext);
80-
}, SubstFlags::SubstituteOpaqueArchetypes);
80+
},
81+
SubstFlags::SubstituteOpaqueArchetypes |
82+
SubstFlags::PreservePackExpansionLevel);
8183
}
8284

8385
// Substitute a function type.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// RUN: %target-swift-frontend -emit-ir %s -disable-availability-checking
2+
3+
struct ZipCollection<each C: Collection> {
4+
let c: (repeat each C)
5+
}
6+
7+
extension ZipCollection: Collection {
8+
struct Element {
9+
var elt: (repeat each C.Element)
10+
}
11+
12+
struct Index {
13+
let i: (repeat each C.Index)
14+
}
15+
16+
var startIndex: Index {
17+
Index(i: (repeat (each c).startIndex))
18+
}
19+
20+
var endIndex: Index {
21+
Index(i: (repeat (each c).endIndex))
22+
}
23+
24+
func index(after i: Index) -> Index {
25+
Index(i: (repeat (each c).index(after: each i.i)))
26+
}
27+
28+
subscript(index: Index) -> Element {
29+
Element(elt: (repeat (each c)[each index.i]))
30+
}
31+
}
32+
33+
extension ZipCollection.Index: Equatable {
34+
static func ==(lhs: Self, rhs: Self) -> Bool {
35+
var result = true
36+
repeat result = ((each lhs.i) == (each rhs.i)) && result
37+
return result
38+
}
39+
}
40+
41+
extension ZipCollection.Index: Comparable {
42+
static func <(lhs: Self, rhs: Self) -> Bool {
43+
var result: Bool? = nil
44+
func check<T: Comparable>(_ x: T, _ y: T) {
45+
if result == nil {
46+
if x == y { return }
47+
if x < y { result = true }
48+
if x > y { result = false }
49+
}
50+
}
51+
repeat check(each lhs.i, each rhs.i)
52+
return result ?? false
53+
}
54+
}

0 commit comments

Comments
 (0)