Skip to content

Commit 5571de1

Browse files
authored
Merge pull request #64676 from xedin/rdar-107280056
[ConstraintSystem] `openOpaqueType`: remove logic that duplicates `bindArchetypesFromContext`
2 parents e4e5af9 + 7f87e6b commit 5571de1

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,22 +1009,11 @@ Type ConstraintSystem::openOpaqueType(OpaqueTypeArchetypeType *opaque,
10091009
// underlying return type.
10101010
auto opaqueLocator = locator.withPathElement(
10111011
LocatorPathElt::OpenedOpaqueArchetype(opaqueDecl));
1012+
10121013
OpenedTypeMap replacements;
10131014
openGeneric(DC, opaqueDecl->getOpaqueInterfaceGenericSignature(),
10141015
opaqueLocator, replacements);
10151016

1016-
// If there is an outer generic signature, bind the outer parameters based
1017-
// on the substitutions in the opaque type.
1018-
auto subs = opaque->getSubstitutions();
1019-
if (auto genericSig = subs.getGenericSignature()) {
1020-
for (auto *genericParamPtr : genericSig.getGenericParams()) {
1021-
Type genericParam(genericParamPtr);
1022-
addConstraint(
1023-
ConstraintKind::Bind, openType(genericParam, replacements),
1024-
genericParam.subst(subs), opaqueLocator);
1025-
}
1026-
}
1027-
10281017
recordOpenedTypes(opaqueLocatorKey, replacements);
10291018

10301019
return openType(opaque->getInterfaceType(), replacements);
@@ -1773,6 +1762,8 @@ static void bindArchetypesFromContext(
17731762
auto genericSig = parentDC->getGenericSignatureOfContext();
17741763
for (auto *paramTy : genericSig.getGenericParams()) {
17751764
Type contextTy = cs.DC->mapTypeIntoContext(paramTy);
1765+
if (paramTy->isParameterPack())
1766+
contextTy = PackType::getSingletonPackExpansion(contextTy);
17761767
bindPrimaryArchetype(paramTy, contextTy);
17771768
}
17781769

test/Constraints/pack-expansion-expressions.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -enable-experimental-feature VariadicGenerics
1+
// RUN: %target-typecheck-verify-swift -disable-availability-checking -enable-experimental-feature VariadicGenerics
22

33
// REQUIRES: asserts
44

@@ -339,3 +339,18 @@ func test_pack_expansion_specialization() {
339339
_ = Data<Int, String>(42, "") // Ok
340340
_ = Data<Int>(42, "") // expected-error {{extra argument in call}}
341341
}
342+
343+
// rdar://107280056 - "Ambiguous without more context" with opaque return type + variadics
344+
protocol Q {
345+
associatedtype B
346+
}
347+
348+
do {
349+
struct G<each T>: Q {
350+
typealias B = (repeat each T)
351+
}
352+
353+
func f<each T>(_: repeat each T) -> some Q {
354+
return G<repeat each T>() // Ok
355+
}
356+
}

0 commit comments

Comments
 (0)