Skip to content

Commit 764e33e

Browse files
committed
Sema: Workaround for issues with openType() and generic parameter packs
1 parent feea23d commit 764e33e

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,8 +1009,11 @@ Type ConstraintSystem::openType(Type type, OpenedTypeMap &replacements,
10091009
// that gets introduced by the interface type, see
10101010
// \c openUnboundGenericType for more details.
10111011
if (auto *packTy = type->getAs<PackType>()) {
1012-
if (auto expansion = packTy->unwrapSingletonPackExpansion())
1013-
type = expansion->getPatternType();
1012+
if (auto expansion = packTy->unwrapSingletonPackExpansion()) {
1013+
auto patternTy = expansion->getPatternType();
1014+
if (patternTy->is<GenericTypeParamType>())
1015+
type = patternTy;
1016+
}
10141017
}
10151018

10161019
if (auto *expansion = type->getAs<PackExpansionType>()) {

validation-test/compiler_crashers_2_fixed/rdar112108253.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ public protocol P {
66

77
public struct G<each T> {}
88

9-
public struct S<T: P, each U: P> where repeat T.A == G<repeat each U> {
10-
public init(predicate: repeat each U) {}
9+
public protocol Q {
10+
init()
11+
}
12+
13+
public struct S<T: P, each U: P>: Q where repeat T.A == G<repeat each U.A> {
14+
public init() {}
15+
public init(predicate: repeat each U) {}
1116
}
1217

0 commit comments

Comments
 (0)