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:
@@ -14,6 +14,7 @@
|
||||
#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
|
||||
#define NS_CONSUMES_SELF __attribute__((ns_consumes_self))
|
||||
#define NS_CONSUMED __attribute__((ns_consumed))
|
||||
#define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
|
||||
|
||||
struct Rect {
|
||||
float x;
|
||||
@@ -38,7 +39,9 @@ typedef long NSInteger;
|
||||
@interface Gizmo : NSObject
|
||||
- (Gizmo*) clone NS_RETURNS_RETAINED;
|
||||
- (Gizmo*) duplicate;
|
||||
- (Gizmo*) initWithBellsOn:(NSInteger)x;
|
||||
- (Gizmo*) init OBJC_DESIGNATED_INITIALIZER;
|
||||
- (Gizmo*) initWithBellsOn:(NSInteger)x OBJC_DESIGNATED_INITIALIZER;
|
||||
- (instancetype) initWithoutBells:(NSInteger)x;
|
||||
- (void) fork NS_CONSUMES_SELF;
|
||||
- (void) enumerateSubGizmos: (void (^)(Gizmo*))f;
|
||||
+ (void) consume: (NS_CONSUMED Gizmo*) gizmo;
|
||||
|
||||
Reference in New Issue
Block a user