Skip to content

Commit af06f29

Browse files
committed
---
yaml --- r: 349049 b: refs/heads/master c: 22bbaea h: refs/heads/master i: 349047: 7a2e379
1 parent e5f5ddb commit af06f29

File tree

3 files changed

+31
-14
lines changed

3 files changed

+31
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: ab31a0d3e9a6f68184bf2e2663b60deaf2af17fa
2+
refs/heads/master: 22bbaea606b2dfffd65650deda35662cf701177a
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/lib/Sema/TypeCheckPropertyWrapper.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -208,24 +208,21 @@ static ConstructorDecl *findDefaultInit(ASTContext &ctx,
208208
nominal->lookupQualified(nominal, initName, NL_QualifiedDefault, decls);
209209
for (const auto &decl : decls) {
210210
auto init = dyn_cast<ConstructorDecl>(decl);
211-
if (!init || init->getDeclContext() != nominal)
211+
if (!init || init->getDeclContext() != nominal || init->isGeneric())
212212
continue;
213213

214+
assert(init->hasParameterList());
214215
// A constructor which does not have any parameters or where all the
215216
// parameters have a default argument can be used to default initialize
216217
// the property wrapper type.
217-
assert(init->hasParameterList());
218-
auto hasParams = init->getParameters()->size() > 0;
219-
auto allParamsHaveDefaultArg = false;
220-
221-
if (hasParams) {
222-
allParamsHaveDefaultArg = llvm::all_of(
223-
init->getParameters()->getArray(),
224-
[](const ParamDecl *decl) { return decl->isDefaultArgument(); });
225-
}
226-
227-
// Skip synthesized default initializers
228-
if (!hasParams || (allParamsHaveDefaultArg && !init->isImplicit())) {
218+
//
219+
// A constructor with no parameters will satisfy the check below.
220+
bool allParamsHaveDefaultArg = llvm::all_of(
221+
init->getParameters()->getArray(),
222+
[](const ParamDecl *decl) { return decl->isDefaultArgument(); });
223+
224+
// Only add non-synthesized initializers.
225+
if (allParamsHaveDefaultArg && !init->isImplicit()) {
229226
defaultValueInitializers.push_back(init);
230227
}
231228
}

trunk/test/SILOptimizer/di_property_wrappers_errors.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,23 @@ struct IntStructWithClassWrapper {
4646
} // expected-error{{return from initializer without initializing all stored properties}}
4747
// expected-note@-1{{'self.wrapped' not initialized}}
4848
}
49+
50+
// SR_11477
51+
52+
@propertyWrapper
53+
struct SR_11477_W {
54+
let name: String
55+
56+
init<T: ExpressibleByIntegerLiteral>(_ value: T = 0) {
57+
self.name = "Init"
58+
}
59+
60+
var wrappedValue: Int {
61+
get { return 0 }
62+
}
63+
}
64+
65+
struct SR_11477_S {
66+
@SR_11477_W var foo: Int
67+
init() {} // expected-error {{return from initializer without initializing all stored properties}} expected-note {{'self.foo' not initialized}}
68+
}

0 commit comments

Comments
 (0)