Skip to content

Commit a911b56

Browse files
committed
---
yaml --- r: 349179 b: refs/heads/master-next c: 9406edc h: refs/heads/master i: 349177: feba36c 349175: d08625e
1 parent 4d998c8 commit a911b56

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 3574c513bbc5578dd9346b4ea9ab5995c5927bb5
3-
refs/heads/master-next: 60bcc9457516cab412b06d9ef907e1ca46bf443e
3+
refs/heads/master-next: 9406edc017f1be00e5411f3abcaccd7b53b15675
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/lib/Sema/CSDiagnostics.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3740,6 +3740,10 @@ bool MissingArgumentsFailure::diagnoseSingleMissingArgument() const {
37403740
if (label.empty()) {
37413741
emitDiagnostic(insertLoc, diag::missing_argument_positional, position + 1)
37423742
.fixItInsert(insertLoc, insertText.str());
3743+
} else if (isPropertyWrapperInitialization()) {
3744+
auto *TE = cast<TypeExpr>(fnExpr);
3745+
emitDiagnostic(TE->getLoc(), diag::property_wrapper_missing_arg_init, label,
3746+
resolveType(TE->getInstanceType())->getString());
37433747
} else {
37443748
emitDiagnostic(insertLoc, diag::missing_argument_named, label)
37453749
.fixItInsert(insertLoc, insertText.str());
@@ -3880,6 +3884,23 @@ bool MissingArgumentsFailure::diagnoseInvalidTupleDestructuring() const {
38803884
return true;
38813885
}
38823886

3887+
bool MissingArgumentsFailure::isPropertyWrapperInitialization() const {
3888+
auto *call = dyn_cast<CallExpr>(getRawAnchor());
3889+
if (!(call && call->isImplicit()))
3890+
return false;
3891+
3892+
auto TE = dyn_cast<TypeExpr>(call->getFn());
3893+
if (!TE)
3894+
return false;
3895+
3896+
auto instanceTy = TE->getInstanceType();
3897+
if (!instanceTy)
3898+
return false;
3899+
3900+
auto *NTD = resolveType(instanceTy)->getAnyNominal();
3901+
return NTD && NTD->getAttrs().hasAttribute<PropertyWrapperAttr>();
3902+
}
3903+
38833904
bool ClosureParamDestructuringFailure::diagnoseAsError() {
38843905
auto *closure = cast<ClosureExpr>(getAnchor());
38853906
auto params = closure->getParameters();

branches/master-next/lib/Sema/CSDiagnostics.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,11 @@ class MissingArgumentsFailure final : public FailureDiagnostic {
12071207
/// Diagnose cases when instead of multiple distinct arguments
12081208
/// call got a single tuple argument with expected arity/types.
12091209
bool diagnoseInvalidTupleDestructuring() const;
1210+
1211+
/// Determine whether missing arguments are associated with
1212+
/// an implicit call to a property wrapper initializer e.g.
1213+
/// `@Foo(answer: 42) var question = "ultimate question"`
1214+
bool isPropertyWrapperInitialization() const;
12101215
};
12111216

12121217
class OutOfOrderArgumentFailure final : public FailureDiagnostic {

0 commit comments

Comments
 (0)