Skip to content

Commit 73a3881

Browse files
authored
Merge pull request #38480 from hborla/5.5-generic-wrapped-parameter-closure
[5.5][CSApply] Always map types out of context when setting interface types for wrapped closure parameters.
2 parents 98b1cf0 + 8f0e249 commit 73a3881

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/Sema/CSApply.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ namespace {
10661066
outerParamTypes.push_back(AnyFunctionType::Param(outerParamType,
10671067
Identifier(),
10681068
paramInfo[i].getParameterFlags()));
1069-
outerParam->setInterfaceType(outerParamType);
1069+
outerParam->setInterfaceType(outerParamType->mapTypeOutOfContext());
10701070

10711071
if (fnDecl.getAbstractFunctionDecl())
10721072
argLabels.push_back(innerParam->getArgumentName());
@@ -8171,11 +8171,12 @@ namespace {
81718171

81728172
if (auto *projectionVar = param->getPropertyWrapperProjectionVar()) {
81738173
projectionVar->setInterfaceType(
8174-
solution.simplifyType(solution.getType(projectionVar)));
8174+
solution.simplifyType(solution.getType(projectionVar))->mapTypeOutOfContext());
81758175
}
81768176

81778177
auto *wrappedValueVar = param->getPropertyWrapperWrappedValueVar();
8178-
auto wrappedValueType = solution.simplifyType(solution.getType(wrappedValueVar));
8178+
auto wrappedValueType =
8179+
solution.simplifyType(solution.getType(wrappedValueVar))->mapTypeOutOfContext();
81798180
wrappedValueVar->setInterfaceType(wrappedValueType->getWithoutSpecifierType());
81808181

81818182
if (param->hasImplicitPropertyWrapper()) {

test/Sema/property_wrapper_parameter.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,9 @@ func testResultBuilderWithImplicitWrapper(@ProjectionWrapper value: String) {
125125
$value
126126
}
127127
}
128+
129+
func takesWrapperClosure<T>(_: ProjectionWrapper<[S<T>]>, closure: (ProjectionWrapper<S<T>>) -> Void) {}
130+
131+
func testGenericPropertyWrapper<U>(@ProjectionWrapper wrappers: [S<U>]) {
132+
takesWrapperClosure($wrappers) { $wrapper in }
133+
}

0 commit comments

Comments
 (0)