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:
Doug Gregor
2014-03-09 07:16:30 +00:00
parent c92f159a8f
commit 00162dc243
10 changed files with 306 additions and 80 deletions

View File

@@ -873,6 +873,12 @@ static bool shouldSerializeMember(Decl *D) {
case DeclKind::EnumCase:
return false;
case DeclKind::Constructor: {
// Never serialize a constructor with a stub implementation.
auto ctor = cast<ConstructorDecl>(D);
return !ctor->hasStubImplementation();
}
case DeclKind::EnumElement:
case DeclKind::Protocol:
case DeclKind::Destructor:
@@ -886,7 +892,6 @@ static bool shouldSerializeMember(Decl *D) {
case DeclKind::Class:
case DeclKind::Var:
case DeclKind::Func:
case DeclKind::Constructor:
return true;
}
}