Skip to content

Commit 16190b0

Browse files
authored
Merge pull request #64955 from xedin/external-wrapper-check-should-use-param-idx
[CSSimplify] Fix external property wrapper check to use parameter index
2 parents 09c3e39 + 0b41ea8 commit 16190b0

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
@@ -1912,11 +1912,14 @@ static ConstraintSystem::TypeMatchResult matchCallArguments(
19121912
}
19131913

19141914
auto argLabel = argument.getLabel();
1915-
if (paramInfo.hasExternalPropertyWrapper(argIdx) || argLabel.hasDollarPrefix()) {
1916-
auto *param = getParameterAt(callee, argIdx);
1915+
if (paramInfo.hasExternalPropertyWrapper(paramIdx) ||
1916+
argLabel.hasDollarPrefix()) {
1917+
auto *param = getParameterAt(callee, paramIdx);
19171918
assert(param);
1918-
if (cs.applyPropertyWrapperToParameter(paramTy, argTy, const_cast<ParamDecl *>(param),
1919-
argLabel, subKind, loc).isFailure()) {
1919+
if (cs.applyPropertyWrapperToParameter(paramTy, argTy,
1920+
const_cast<ParamDecl *>(param),
1921+
argLabel, subKind, loc)
1922+
.isFailure()) {
19201923
return cs.getTypeMatchFailure(loc);
19211924
}
19221925
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)