File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed
lib/SILOptimizer/Mandatory Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -1047,7 +1047,15 @@ void LifetimeChecker::handleStoreUse(unsigned UseID) {
10471047 if (isFullyUninitialized) {
10481048 Use.Kind = DIUseKind::Initialization;
10491049 } else if (isFullyInitialized) {
1050- Use.Kind = DIUseKind::Assign;
1050+ // Only re-write assign_by_wrapper to assignment if all fields have been
1051+ // initialized.
1052+ if (isa<AssignByWrapperInst>(Use.Inst ) &&
1053+ getAnyUninitializedMemberAtInst (Use.Inst , 0 ,
1054+ TheMemory.getNumElements ()) != -1 ) {
1055+ Use.Kind = DIUseKind::Initialization;
1056+ } else {
1057+ Use.Kind = DIUseKind::Assign;
1058+ }
10511059 } else {
10521060 // If it is initialized on some paths, but not others, then we have an
10531061 // inconsistent initialization, which needs dynamic control logic in the
Original file line number Diff line number Diff line change @@ -501,6 +501,37 @@ public final class Synchronized<Value> {
501501 }
502502}
503503
504+ struct SR_12341 {
505+ @Wrapper var wrapped : Int = 10
506+ var str : String
507+
508+ init ( ) {
509+ wrapped = 42
510+ str = " "
511+ wrapped = 27
512+ }
513+
514+ init ( condition: Bool ) {
515+ wrapped = 42
516+ wrapped = 27
517+ str = " "
518+ }
519+ }
520+
521+ func testSR_12341( ) {
522+ // CHECK: ## SR_12341
523+ print ( " \n ## SR_12341 " )
524+
525+ // CHECK-NEXT: .. init 10
526+ // CHECK-NEXT: .. init 42
527+ // CHECK-NEXT: .. set 27
528+ _ = SR_12341 ( )
529+
530+ // CHECK-NEXT: .. init 10
531+ // CHECK-NEXT: .. init 42
532+ // CHECK-NEXT: .. init 27
533+ _ = SR_12341 ( condition: true )
534+ }
504535
505536testIntStruct ( )
506537testIntClass ( )
@@ -511,3 +542,4 @@ testOptIntStruct()
511542testDefaultNilOptIntStruct ( )
512543testComposed ( )
513544testWrapperInitWithDefaultArg ( )
545+ testSR_12341 ( )
You can’t perform that action at this time.
0 commit comments