Fix synthesis of 'override' and 'required' on initializers (#20548)

This is actually two separate problems:
- 'override' wasn't getting added to initializers in deserialization
- 'override' was getting added when inheriting a 'required' initializer,
  even though it's normally an error to write that

Needed for parseable interfaces.
This commit is contained in:
Jordan Rose
2018-11-13 16:54:53 -08:00
committed by GitHub
parent a21a71d7da
commit 40cfc458e2
4 changed files with 54 additions and 9 deletions

View File

@@ -2473,11 +2473,12 @@ configureInheritedDesignatedInitAttributes(TypeChecker &tc,
}
// Wire up the overrides.
ctor->getAttrs().add(new (ctx) OverrideAttr(/*IsImplicit=*/true));
ctor->setOverriddenDecl(superclassCtor);
if (superclassCtor->isRequired())
ctor->getAttrs().add(new (ctx) RequiredAttr(/*IsImplicit=*/true));
ctor->getAttrs().add(new (ctx) RequiredAttr(/*IsImplicit=*/false));
else
ctor->getAttrs().add(new (ctx) OverrideAttr(/*IsImplicit=*/false));
// If the superclass constructor is @objc but the subclass constructor is
// not representable in Objective-C, add @nonobjc implicitly.