Skip to content

Commit 354285f

Browse files
authored
Merge pull request #65714 from xedin/external-wrapper-check-should-use-param-idx-5.9
[5.9][CSSimplify] Fix external property wrapper check to use parameter index
2 parents 196a156 + 1bb8115 commit 354285f

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,11 +1935,14 @@ static ConstraintSystem::TypeMatchResult matchCallArguments(
19351935
}
19361936

19371937
auto argLabel = argument.getLabel();
1938-
if (paramInfo.hasExternalPropertyWrapper(argIdx) || argLabel.hasDollarPrefix()) {
1939-
auto *param = getParameterAt(callee, argIdx);
1938+
if (paramInfo.hasExternalPropertyWrapper(paramIdx) ||
1939+
argLabel.hasDollarPrefix()) {
1940+
auto *param = getParameterAt(callee, paramIdx);
19401941
assert(param);
1941-
if (cs.applyPropertyWrapperToParameter(paramTy, argTy, const_cast<ParamDecl *>(param),
1942-
argLabel, subKind, loc).isFailure()) {
1942+
if (cs.applyPropertyWrapperToParameter(paramTy, argTy,
1943+
const_cast<ParamDecl *>(param),
1944+
argLabel, subKind, loc)
1945+
.isFailure()) {
19431946
return cs.getTypeMatchFailure(loc);
19441947
}
19451948
continue;

test/Sema/property_wrapper_parameter_invalid.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,24 @@ struct NoProjection<T> {
3636
// expected-note@+1 {{property wrapper type 'NoProjection<String>' does not support initialization from a projected value}}
3737
func takesNoProjectionWrapper(@NoProjection value: String) {}
3838

39+
// expected-note@+1 {{property wrapper type 'NoProjection<String>' does not support initialization from a projected value}}
40+
func takesNoProjectionWrapperWithDefault(_: Int? = nil, @NoProjection value: String) {}
41+
42+
// expected-note@+1 {{property wrapper type 'NoProjection<String>' does not support initialization from a projected value}}
43+
func takesNoProjectionWrapperWithVariadic(_: Int..., @NoProjection value: String) {}
44+
3945
func testNoProjection(message: String) {
4046
takesNoProjectionWrapper(value: message) // okay
4147

4248
// expected-error@+1 {{cannot use property wrapper projection argument}}
4349
takesNoProjectionWrapper($value: message)
4450

51+
// expected-error@+1 {{cannot use property wrapper projection argument}}
52+
takesNoProjectionWrapperWithDefault($value: message)
53+
54+
// expected-error@+1 {{cannot use property wrapper projection argument}}
55+
takesNoProjectionWrapperWithVariadic(1, 2, 3, $value: message)
56+
4557
// expected-error@+2 {{cannot use property wrapper projection parameter}}
4658
// expected-note@+1 {{property wrapper type 'NoProjection<Int>' does not support initialization from a projected value}}
4759
let _: (NoProjection<Int>) -> Int = { $value in

0 commit comments

Comments
 (0)