mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Start emitting stubs for unimplemented designated initializers of the superclass.
When a subclass does not implement a designated initializer of its superclass, introduce a stub initializer that simply traps. Such stubs cannot be invoked directly using Swift syntax, but can be invoked through the Objective-C runtime and from Objective-C code. Catch such errors rather than allowing them to violate the memory safety of the language. Note that we're currently using cond_fail to trap; this will be improved in the future, Swift SVN r14839
This commit is contained in:
@@ -1155,6 +1155,10 @@ bool ClassDecl::inheritsSuperclassInitializers(LazyResolver *resolver) {
|
||||
if (!ctor->hasType())
|
||||
resolver->resolveDeclSignature(ctor);
|
||||
|
||||
// Ignore any stub implementations.
|
||||
if (ctor->hasStubImplementation())
|
||||
continue;
|
||||
|
||||
if (auto overridden = ctor->getOverriddenDecl()) {
|
||||
if (overridden->isSubobjectInit())
|
||||
overriddenInits.insert(overridden);
|
||||
@@ -1983,6 +1987,7 @@ ConstructorDecl::ConstructorDecl(Identifier NameHack, SourceLoc ConstructorLoc,
|
||||
ConstructorDeclBits.ComputedBodyInitKind = 0;
|
||||
ConstructorDeclBits.Required = 0;
|
||||
ConstructorDeclBits.CompleteObjectInit = 0;
|
||||
ConstructorDeclBits.HasStubImplementation = 0;
|
||||
}
|
||||
|
||||
void ConstructorDecl::setArgParams(Pattern *selfPattern, Pattern *argParams) {
|
||||
|
||||
Reference in New Issue
Block a user