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 {
13241324 if (!initInfo.hasInitFromWrappedValue ())
13251325 return false ;
13261326
1327+ auto *fnDecl = SGF.FunctionDC ->getAsDecl ();
13271328 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 ());
13301333
13311334 // Assignment to a wrapped property can only be re-written to initialization for
13321335 // 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 {
9292 }
9393 wrapped = 27
9494 }
95+
96+ convenience init ( withConvenienceInit x: Int ) {
97+ self . init ( )
98+ self . wrapped = x
99+ }
95100}
96101
97102struct RefStruct {
@@ -210,6 +215,13 @@ func testIntClass() {
210215 let t5 = IntClass ( dynamic: true )
211216 // CHECK-NEXT: 27
212217 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)
213225}
214226
215227func testRefStruct( ) {
You can’t perform that action at this time.
0 commit comments