Skip to content

Commit b32ef4e

Browse files
xedinslavapestov
authored andcommitted
[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 a592bad commit b32ef4e

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
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: 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

@@ -381,3 +381,18 @@ do {
381381
_ = Defaulted(t: "b", 0) // Ok
382382
_ = Defaulted(t: "c", 1.0, u: "d", 0) // Ok
383383
}
384+
385+
// rdar://107280056 - "Ambiguous without more context" with opaque return type + variadics
386+
protocol Q {
387+
associatedtype B
388+
}
389+
390+
do {
391+
struct G<each T>: Q {
392+
typealias B = (repeat each T)
393+
}
394+
395+
func f<each T>(_: repeat each T) -> some Q {
396+
return G<repeat each T>() // Ok
397+
}
398+
}

0 commit comments

Comments
 (0)