Skip to content

Commit 015e8f7

Browse files
authored
Merge pull request #24211 from slavapestov/declutter-ast-context
Declutter ASTContext by moving @objc diagnostics to Sema
2 parents 5cb1c6a + 949fe16 commit 015e8f7

File tree

8 files changed

+721
-866
lines changed

8 files changed

+721
-866
lines changed

include/swift/AST/ASTContext.h

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -839,40 +839,6 @@ class ASTContext final {
839839
/// Returns memory used exclusively by constraint solver.
840840
size_t getSolverMemory() const;
841841

842-
/// Complain if @objc or dynamic is used without importing Foundation.
843-
void diagnoseAttrsRequiringFoundation(SourceFile &SF);
844-
845-
/// Note that the given method produces an Objective-C method.
846-
void recordObjCMethod(AbstractFunctionDecl *method);
847-
848-
/// Diagnose any Objective-C method overrides that aren't reflected
849-
/// as overrides in Swift.
850-
bool diagnoseUnintendedObjCMethodOverrides(SourceFile &sf);
851-
852-
/// Note that there is a conflict between different definitions that
853-
/// produce the same Objective-C method.
854-
void recordObjCMethodConflict(ClassDecl *classDecl, ObjCSelector selector,
855-
bool isInstance);
856-
857-
/// Diagnose all conflicts between members that have the same
858-
/// Objective-C selector in the same class.
859-
///
860-
/// \param sf The source file for which we are diagnosing conflicts.
861-
///
862-
/// \returns true if there were any conflicts diagnosed.
863-
bool diagnoseObjCMethodConflicts(SourceFile &sf);
864-
865-
/// Note that an optional @objc requirement has gone unsatisfied by
866-
/// a conformance to its protocol.
867-
///
868-
/// \param dc The declaration context in which the conformance occurs.
869-
/// \param req The optional requirement.
870-
void recordObjCUnsatisfiedOptReq(DeclContext *dc, AbstractFunctionDecl *req);
871-
872-
/// Diagnose any unsatisfied @objc optional requirements of
873-
/// protocols that conflict with methods.
874-
bool diagnoseObjCUnsatisfiedOptReqConflicts(SourceFile &sf);
875-
876842
/// Retrieve the Swift name for the given Foundation entity, where
877843
/// "NS" prefix stripping will apply under omit-needless-words.
878844
StringRef getSwiftName(KnownFoundationEntity kind);
@@ -951,31 +917,6 @@ class ASTContext final {
951917
friend SILBoxType;
952918
};
953919

954-
/// Retrieve information about the given Objective-C method for
955-
/// diagnostic purposes, to be used with OBJC_DIAG_SELECT in
956-
/// DiagnosticsSema.def.
957-
std::pair<unsigned, DeclName> getObjCMethodDiagInfo(
958-
AbstractFunctionDecl *method);
959-
960-
/// Attach Fix-Its to the given diagnostic that updates the name of the
961-
/// given declaration to the desired target name.
962-
///
963-
/// \returns false if the name could not be fixed.
964-
bool fixDeclarationName(InFlightDiagnostic &diag, ValueDecl *decl,
965-
DeclName targetName);
966-
967-
/// Fix the Objective-C name of the given declaration to match the provided
968-
/// Objective-C selector.
969-
///
970-
/// \param ignoreImpliedName When true, ignore the implied name of the
971-
/// given declaration, because it no longer applies.
972-
///
973-
/// For properties, the selector should be a zero-parameter selector of the
974-
/// given property's name.
975-
bool fixDeclarationObjCName(InFlightDiagnostic &diag, ValueDecl *decl,
976-
Optional<ObjCSelector> targetNameOpt,
977-
bool ignoreImpliedName = false);
978-
979920
} // end namespace swift
980921

981922
#endif

include/swift/AST/Module.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,22 @@ class SourceFile final : public FileUnit {
10281028
llvm::DenseMap<ObjCSelector, llvm::TinyPtrVector<AbstractFunctionDecl *>>
10291029
ObjCMethods;
10301030

1031+
/// List of Objective-C methods, which is used for checking unintended
1032+
/// Objective-C overrides.
1033+
std::vector<AbstractFunctionDecl *> ObjCMethodList;
1034+
1035+
/// An unsatisfied, optional @objc requirement in a protocol conformance.
1036+
using ObjCUnsatisfiedOptReq = std::pair<DeclContext *, AbstractFunctionDecl *>;
1037+
1038+
/// List of optional @objc protocol requirements that have gone
1039+
/// unsatisfied, which might conflict with other Objective-C methods.
1040+
std::vector<ObjCUnsatisfiedOptReq> ObjCUnsatisfiedOptReqs;
1041+
1042+
using ObjCMethodConflict = std::tuple<ClassDecl *, ObjCSelector, bool>;
1043+
1044+
/// List of Objective-C member conflicts we have found during type checking.
1045+
std::vector<ObjCMethodConflict> ObjCMethodConflicts;
1046+
10311047
template <typename T>
10321048
using OperatorMap = llvm::DenseMap<Identifier,llvm::PointerIntPair<T,1,bool>>;
10331049

0 commit comments

Comments
 (0)