DI: All enum initializers should be delegating

Again, since there's no distinction between an enum initializer that
delegates to 'self.init' from one that assigns to 'self', we can remove
the special handling of enum initializers in the 'root self' case.

Now, 'root self' is only used for designated initializers in classes
with no superclass, and struct initializers that perform memberwise
initialization of stored properties.

This regresses some diagnostics, because the logic for delegating
init diagnostics is missing some heuristics present in the root self
case. I will fix this in a subsequent patch.
This commit is contained in:
Slava Pestov
2017-10-12 18:02:45 -07:00
parent 0c16aedb60
commit b5eeae7446
5 changed files with 16 additions and 39 deletions

View File

@@ -1567,13 +1567,6 @@ void LifetimeChecker::handleLoadUseFailure(const DIMemoryUse &Use,
}
}
if (TheMemory.isEnumInitSelf()) {
if (!shouldEmitError(Inst)) return;
diagnose(Module, returnLoc,
diag::return_from_init_without_initing_self);
return;
}
if (TheMemory.isAnyInitSelf() && !TheMemory.isClassInitSelf() &&
!TheMemory.isDelegatingInit()) {
if (!shouldEmitError(Inst)) return;
@@ -1593,13 +1586,6 @@ void LifetimeChecker::handleLoadUseFailure(const DIMemoryUse &Use,
if (CA->isInitializationOfDest() &&
!CA->getFunction()->getArguments().empty() &&
SILValue(CA->getFunction()->getArgument(0)) == CA->getDest()) {
if (TheMemory.isEnumInitSelf()) {
if (!shouldEmitError(Inst)) return;
diagnose(Module, Inst->getLoc(),
diag::return_from_init_without_initing_self);
return;
}
if (TheMemory.isAnyInitSelf() && !TheMemory.isClassInitSelf() &&
!TheMemory.isDelegatingInit()) {
if (!shouldEmitError(Inst)) return;