Diagnose redeclarations of Objective-C methods.

@objc methods, initializers, deinitializers, properties, and
subscripts all produce Objective-C methods. Diagnose cases where two
such entities (which may be of different kinds) produce the same
Objective-C method in the same class.

As a special exception, one can have an Objective-C method in an
extension that conflicts with an Objective-C method in the original
class definition, so long as the original class definition is from a
different model. This reflects the reality in Objective-C that the
category definition wins over the original definition, and is used in
at least one overlay (SpriteKit).

This is the first part of rdar://problem/18391046; the second part
involves checking that overrides are sane.

Swift SVN r23147
This commit is contained in:
Doug Gregor
2014-11-07 01:15:14 +00:00
parent e70ca2762d
commit 89e5e5b6fa
26 changed files with 671 additions and 179 deletions

View File

@@ -642,6 +642,19 @@ public:
/// \brief Returns memory used exclusively by constraint solver.
size_t getSolverMemory() const;
/// Note that there is a conflict between different definitions that
/// produce the same Objective-C method.
void recordObjCMethodConflict(ClassDecl *classDecl, ObjCSelector selector,
bool isInstance);
/// Diagnose all conflicts between members that have the same
/// Objective-C selector in the same class.
///
/// \param sf The source file for which we are diagnosing conflicts.
///
/// \returns true if there were any conflicts diagnosed.
bool diagnoseObjCMethodConflicts(SourceFile &sf);
private:
friend class Decl;
Optional<RawComment> getRawComment(const Decl *D);