mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Start parsing 'throws' on initializers.
Introduce basic validation for throwing @objc initializers, e.g., a failable @objc initializer cannot also be throwing. However, Objective-C selector computation is broken. Swift SVN r27292
This commit is contained in:
@@ -5275,6 +5275,9 @@ class ConstructorDecl : public AbstractFunctionDecl {
|
||||
/// The location of the '!' or '?' for a failable initializer.
|
||||
SourceLoc FailabilityLoc;
|
||||
|
||||
// Location of the 'throws' token.
|
||||
SourceLoc ThrowsLoc;
|
||||
|
||||
Pattern *BodyParams[2];
|
||||
|
||||
/// The type of the initializing constructor.
|
||||
@@ -5295,7 +5298,8 @@ public:
|
||||
ConstructorDecl(DeclName Name, SourceLoc ConstructorLoc,
|
||||
OptionalTypeKind Failability, SourceLoc FailabilityLoc,
|
||||
Pattern *SelfBodyParam, Pattern *BodyParams,
|
||||
GenericParamList *GenericParams, DeclContext *Parent);
|
||||
GenericParamList *GenericParams,
|
||||
SourceLoc throwsLoc, DeclContext *Parent);
|
||||
|
||||
void setBodyParams(Pattern *selfPattern, Pattern *bodyParams);
|
||||
|
||||
@@ -5417,6 +5421,9 @@ public:
|
||||
/// Retrieve the location of the '!' or '?' in a failable initializer.
|
||||
SourceLoc getFailabilityLoc() const { return FailabilityLoc; }
|
||||
|
||||
/// Retrieve the location of the 'throws' keyword, if present.
|
||||
SourceLoc getThrowsLoc() const { return ThrowsLoc; }
|
||||
|
||||
/// Whether the implementation of this method is a stub that traps at runtime.
|
||||
bool hasStubImplementation() const {
|
||||
return ConstructorDeclBits.HasStubImplementation;
|
||||
|
||||
@@ -1918,6 +1918,10 @@ ERROR(objc_invalid_on_throwing_result,sema_objc,none,
|
||||
"it returns a value of type %1; return 'Void' or a type that bridges "
|
||||
"to an Objective-C class",
|
||||
(unsigned, Type))
|
||||
ERROR(objc_invalid_on_failing_init,sema_objc,none,
|
||||
"a failable and throwing initializer cannot be marked "
|
||||
"%" OBJC_ATTR_SELECT "0 because 'nil' indicates failure to Objective-C",
|
||||
(unsigned))
|
||||
|
||||
#undef OBJC_ATTR_SELECT
|
||||
|
||||
|
||||
Reference in New Issue
Block a user