File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -1324,9 +1324,12 @@ namespace {
1324
1324
if (!initInfo.hasInitFromWrappedValue ())
1325
1325
return false ;
1326
1326
1327
+ auto *fnDecl = SGF.FunctionDC ->getAsDecl ();
1327
1328
bool isAssignmentToSelfParamInInit =
1328
- IsOnSelfParameter &&
1329
- isa<ConstructorDecl>(SGF.FunctionDC ->getAsDecl ());
1329
+ IsOnSelfParameter && isa<ConstructorDecl>(fnDecl) &&
1330
+ // Convenience initializers only contain assignments and not
1331
+ // initializations.
1332
+ !(cast<ConstructorDecl>(fnDecl)->isConvenienceInit ());
1330
1333
1331
1334
// Assignment to a wrapped property can only be re-written to initialization for
1332
1335
// members of `self` in an initializer, and for local variables.
Original file line number Diff line number Diff line change @@ -92,6 +92,11 @@ final class IntClass {
92
92
}
93
93
wrapped = 27
94
94
}
95
+
96
+ convenience init ( withConvenienceInit x: Int ) {
97
+ self . init ( )
98
+ self . wrapped = x
99
+ }
95
100
}
96
101
97
102
struct RefStruct {
@@ -210,6 +215,13 @@ func testIntClass() {
210
215
let t5 = IntClass ( dynamic: true )
211
216
// CHECK-NEXT: 27
212
217
print ( t5. wrapped)
218
+
219
+ // CHECK-NEXT: .. init 42
220
+ // CHECK-NEXT: .. set 27
221
+ // CHECK-NEXT: .. set 123
222
+ let t6 = IntClass ( withConvenienceInit: 123 )
223
+ // CHECK-NEXT: 123
224
+ print ( t6. wrapped)
213
225
}
214
226
215
227
func testRefStruct( ) {
You can’t perform that action at this time.
0 commit comments