Skip to content

Commit b8d0ba9

Browse files
committed
AST: Fix substOpaqueTypesWithUnderlyingTypes() to set SubstFlags::PreservePackExpansionLevel
The "iterate until fixed point" would cause an infinite loop where we wrap type parameter packs in a PackElementType and increase the level forever otherwise. This was a regression from commit 103428f. Fixes rdar://160804717.
1 parent dc759fd commit b8d0ba9

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

lib/AST/TypeSubstitution.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,8 @@ ProtocolConformanceRef swift::substOpaqueTypesWithUnderlyingTypes(
10931093
context.getContext(), context.getResilienceExpansion(),
10941094
context.isWholeModuleContext());
10951095
InFlightSubstitution IFS(replacer, replacer,
1096-
SubstFlags::SubstituteOpaqueArchetypes);
1096+
SubstFlags::SubstituteOpaqueArchetypes |
1097+
SubstFlags::PreservePackExpansionLevel);
10971098

10981099
auto substRef = ref.subst(IFS);
10991100

test/Generics/rdar160804717.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RUN: %target-swift-frontend -emit-ir %s -target %target-swift-5.9-abi-triple
2+
// REQUIRES: objc_interop
3+
4+
// This used to trigger an infinite loop in conformance substitution
5+
// when emitting the opaque type descriptor in IRGen.
6+
7+
// rdar://160804717
8+
9+
import SwiftUI
10+
11+
public struct CategorySplitView<each Destination: View>: View {
12+
let titleKey: LocalizedStringKey
13+
let groups: (repeat each Destination)
14+
15+
public var body: some View {
16+
TupleView((repeat CategoryGroupSidebar(group: each groups))).navigationTitle(titleKey)
17+
}
18+
}
19+
20+
public struct CategoryGroupSidebar<Destination>: View {
21+
let group: Destination
22+
23+
public var body: some View {
24+
Text("Hi")
25+
}
26+
}
27+

0 commit comments

Comments
 (0)