Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions lib/Sema/CSSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1935,11 +1935,14 @@ static ConstraintSystem::TypeMatchResult matchCallArguments(
}

auto argLabel = argument.getLabel();
if (paramInfo.hasExternalPropertyWrapper(argIdx) || argLabel.hasDollarPrefix()) {
auto *param = getParameterAt(callee, argIdx);
if (paramInfo.hasExternalPropertyWrapper(paramIdx) ||
argLabel.hasDollarPrefix()) {
auto *param = getParameterAt(callee, paramIdx);
assert(param);
if (cs.applyPropertyWrapperToParameter(paramTy, argTy, const_cast<ParamDecl *>(param),
argLabel, subKind, loc).isFailure()) {
if (cs.applyPropertyWrapperToParameter(paramTy, argTy,
const_cast<ParamDecl *>(param),
argLabel, subKind, loc)
.isFailure()) {
return cs.getTypeMatchFailure(loc);
}
continue;
Expand Down
12 changes: 12 additions & 0 deletions test/Sema/property_wrapper_parameter_invalid.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,24 @@ struct NoProjection<T> {
// expected-note@+1 {{property wrapper type 'NoProjection<String>' does not support initialization from a projected value}}
func takesNoProjectionWrapper(@NoProjection value: String) {}

// expected-note@+1 {{property wrapper type 'NoProjection<String>' does not support initialization from a projected value}}
func takesNoProjectionWrapperWithDefault(_: Int? = nil, @NoProjection value: String) {}

// expected-note@+1 {{property wrapper type 'NoProjection<String>' does not support initialization from a projected value}}
func takesNoProjectionWrapperWithVariadic(_: Int..., @NoProjection value: String) {}

func testNoProjection(message: String) {
takesNoProjectionWrapper(value: message) // okay

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

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

// expected-error@+1 {{cannot use property wrapper projection argument}}
takesNoProjectionWrapperWithVariadic(1, 2, 3, $value: message)

// expected-error@+2 {{cannot use property wrapper projection parameter}}
// expected-note@+1 {{property wrapper type 'NoProjection<Int>' does not support initialization from a projected value}}
let _: (NoProjection<Int>) -> Int = { $value in
Expand Down