Skip to content

Commit e42d8af

Browse files
committed
[ConstraintSystem] openOpaqueType: remove logic that duplicates bindArchetypesFromContext
`openGenericParameters` calls `bindArchetypesFromContext` which would bind all of the external generic parameters in the opaque type signature. Resolves: rdar://107280056
1 parent a9491f6 commit e42d8af

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 1 addition & 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);

test/Constraints/pack-expansion-expressions.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,18 @@ func test_pack_expansion_specialization() {
318318
_ = Data<Int, String>(42, "") // Ok
319319
_ = Data<Int>(42, "") // expected-error {{extra argument in call}}
320320
}
321+
322+
// rdar://107280056 - "Ambiguous without more context" with opaque return type + variadics
323+
protocol Q {
324+
associatedtype B
325+
}
326+
327+
do {
328+
struct G<each T>: Q {
329+
typealias B = (repeat each T)
330+
}
331+
332+
func f<each T>(_: repeat each T) -> some Q {
333+
return G<repeat each T>()
334+
}
335+
}

0 commit comments

Comments
 (0)