Skip to content

Commit d03f97d

Browse files
committed
Revert "[ConstraintSystem] Adjust the way pack parameters are opened"
This reverts commit 2227930.
1 parent 0f07119 commit d03f97d

File tree

2 files changed

+1
-51
lines changed

2 files changed

+1
-51
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -855,21 +855,7 @@ Type ConstraintSystem::openUnboundGenericType(GenericTypeDecl *decl,
855855
result = DC->mapTypeIntoContext(result);
856856
}
857857

858-
return result.transform([&](Type type) -> Type {
859-
// Although generic parameters are declared with just `each`
860-
// their interface types introduce a pack expansion which
861-
// means that the solver has to extact generic argument type
862-
// variable from Pack{repeat ...} and drop that structure to
863-
// make sure that generic argument gets inferred to a pack type.
864-
if (auto *packTy = type->getAs<PackType>()) {
865-
assert(packTy->getNumElements() == 1);
866-
auto *expansion = packTy->getElementType(0)->castTo<PackExpansionType>();
867-
auto *typeVar = expansion->getPatternType()->castTo<TypeVariableType>();
868-
assert(typeVar->getImpl().getGenericParameter() &&
869-
typeVar->getImpl().canBindToPack());
870-
return typeVar;
871-
}
872-
858+
return result.transform([&](Type type) {
873859
if (auto *expansion = dyn_cast<PackExpansionType>(type.getPointer()))
874860
return openPackExpansionType(expansion, replacements, locator);
875861
return type;
@@ -1022,15 +1008,6 @@ Type ConstraintSystem::openType(Type type, OpenedTypeMap &replacements,
10221008
}
10231009
}
10241010

1025-
// While opening variadic generic types that appear in other types
1026-
// we need to extract generic parameter from Pack{repeat ...} structure
1027-
// that gets introduced by the interface type, see
1028-
// \c openUnboundGenericType for more details.
1029-
if (auto *packTy = type->getAs<PackType>()) {
1030-
if (auto expansion = packTy->unwrapSingletonPackExpansion())
1031-
type = expansion->getPatternType();
1032-
}
1033-
10341011
if (auto *expansion = type->getAs<PackExpansionType>()) {
10351012
return openPackExpansionType(expansion, replacements, locator);
10361013
}

test/Constraints/variadic_generic_types.swift

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,3 @@ struct MissingMemberError<each T> {
2929
// expected-error@-1 {{value of type 'MissingMemberError<repeat each T>' has no member 'doesNotExist'}}
3030
}
3131
}
32-
33-
// https://github.com/apple/swift/issues/66095
34-
do {
35-
struct Test<each S> {
36-
init(_ s: repeat each S) {}
37-
}
38-
39-
func test1<each T>(_ v: repeat each T) -> Test<repeat each T> {
40-
return Test(repeat each v) // Ok
41-
}
42-
43-
func test2<each T>(_ v: repeat each T) -> Test<repeat each T> {
44-
return Test<repeat each T>(repeat each v) // Ok
45-
}
46-
47-
func test3<each T>(_ v: repeat each T) -> Test<String, repeat each T, Int> {
48-
return Test("a", repeat each v, 42) // Ok
49-
}
50-
51-
func test4<each T>(_ v: repeat each T) -> Test<repeat each T, String, Int> {
52-
return Test<repeat each T, String, Int>(repeat each v, "a", 42) // Ok
53-
}
54-
55-
func test5<each T>(_ v: repeat each T) -> Test<String, Int, repeat each T> {
56-
return Test<String, Int, repeat each T>("a", 42, repeat each v) // Ok
57-
}
58-
}

0 commit comments

Comments
 (0)