Skip to content

Commit 9e73dad

Browse files
authored
Merge pull request #67342 from slavapestov/open-type-workaround
Sema: Workaround for issue in ConstraintSystem::openType()
2 parents 76c90f6 + 415b705 commit 9e73dad

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
@@ -1027,8 +1027,11 @@ Type ConstraintSystem::openType(Type type, OpenedTypeMap &replacements,
10271027
// that gets introduced by the interface type, see
10281028
// \c openUnboundGenericType for more details.
10291029
if (auto *packTy = type->getAs<PackType>()) {
1030-
if (auto expansion = packTy->unwrapSingletonPackExpansion())
1031-
type = expansion->getPatternType();
1030+
if (auto expansionTy = packTy->unwrapSingletonPackExpansion()) {
1031+
auto patternTy = expansionTy->getPatternType();
1032+
if (patternTy->isTypeParameter())
1033+
return openType(patternTy, replacements, locator);
1034+
}
10321035
}
10331036

10341037
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)