Skip to content

Commit a9bd6b5

Browse files
committed
[CSApply] Always map types out of context when setting interface types for wrapped
closure parameters.
1 parent df7656e commit a9bd6b5

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
@@ -1067,7 +1067,7 @@ namespace {
10671067
outerParamTypes.push_back(AnyFunctionType::Param(outerParamType,
10681068
Identifier(),
10691069
paramInfo[i].getParameterFlags()));
1070-
outerParam->setInterfaceType(outerParamType);
1070+
outerParam->setInterfaceType(outerParamType->mapTypeOutOfContext());
10711071

10721072
if (fnDecl.getAbstractFunctionDecl())
10731073
argLabels.push_back(innerParam->getArgumentName());
@@ -8151,11 +8151,12 @@ namespace {
81518151

81528152
if (auto *projectionVar = param->getPropertyWrapperProjectionVar()) {
81538153
projectionVar->setInterfaceType(
8154-
solution.simplifyType(solution.getType(projectionVar)));
8154+
solution.simplifyType(solution.getType(projectionVar))->mapTypeOutOfContext());
81558155
}
81568156

81578157
auto *wrappedValueVar = param->getPropertyWrapperWrappedValueVar();
8158-
auto wrappedValueType = solution.simplifyType(solution.getType(wrappedValueVar));
8158+
auto wrappedValueType =
8159+
solution.simplifyType(solution.getType(wrappedValueVar))->mapTypeOutOfContext();
81598160
wrappedValueVar->setInterfaceType(wrappedValueType->getWithoutSpecifierType());
81608161

81618162
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)