File tree Expand file tree Collapse file tree 2 files changed +28
-7
lines changed
lib/SILOptimizer/Mandatory Expand file tree Collapse file tree 2 files changed +28
-7
lines changed Original file line number Diff line number Diff line change @@ -973,13 +973,6 @@ void LifetimeChecker::emitSelfConsumedDiagnostic(SILInstruction *Inst) {
973
973
void LifetimeChecker::handleStoreUse (unsigned UseID) {
974
974
DIMemoryUse &InstInfo = Uses[UseID];
975
975
976
- if (TheMemory.isAnyInitSelf ()) {
977
- if (getSelfConsumedAtInst (InstInfo.Inst ) != DIKind::No) {
978
- emitSelfConsumedDiagnostic (InstInfo.Inst );
979
- return ;
980
- }
981
- }
982
-
983
976
// Determine the liveness state of the element that we care about.
984
977
auto Liveness = getLivenessAtInst (InstInfo.Inst , InstInfo.FirstElement ,
985
978
InstInfo.NumElements );
@@ -997,6 +990,17 @@ void LifetimeChecker::handleStoreUse(unsigned UseID) {
997
990
isFullyUninitialized = false ;
998
991
}
999
992
993
+ if (TheMemory.isNonRootClassSelf ()) {
994
+ if (getSelfInitializedAtInst (InstInfo.Inst ) != DIKind::Yes) {
995
+ auto SelfLiveness = getLivenessAtInst (InstInfo.Inst ,
996
+ 0 , TheMemory.NumElements );
997
+ if (SelfLiveness.isAllYes ()) {
998
+ emitSelfConsumedDiagnostic (InstInfo.Inst );
999
+ return ;
1000
+ }
1001
+ }
1002
+ }
1003
+
1000
1004
// If this is a partial store into a struct and the whole struct hasn't been
1001
1005
// initialized, diagnose this as an error.
1002
1006
if (InstInfo.Kind == DIUseKind::PartialStore && !isFullyInitialized) {
Original file line number Diff line number Diff line change @@ -1230,3 +1230,20 @@ class SuperConvenienceSub : SuperConvenienceBase {
1230
1230
self . init ( i1, i1)
1231
1231
}
1232
1232
}
1233
+
1234
+ // While testing some changes I found this regression that wasn't
1235
+ // covered by any existing tests
1236
+ class Base { }
1237
+
1238
+ func makeAnAny( ) -> Any { return 3 }
1239
+
1240
+ class Derived : Base {
1241
+ var x : Int ?
1242
+ var y : Int ?
1243
+
1244
+ override init ( ) {
1245
+ x = makeAnAny ( ) as? Int
1246
+ y = makeAnAny ( ) as? Int
1247
+ super. init ( )
1248
+ }
1249
+ }
You can’t perform that action at this time.
0 commit comments