Iterative type checker: compute inherited protocols of a protocol.

Introduce a type check request for computing inherited protocols and
start using it in a few places.

Swift SVN r32562
This commit is contained in:
Doug Gregor
2015-10-09 17:18:40 +00:00
parent 68604e6b61
commit f247447f03
9 changed files with 108 additions and 10 deletions

View File

@@ -20,6 +20,7 @@
#define SWIFT_SEMA_ITERATIVE_TYPE_CHECKER_H
#include "swift/Sema/TypeCheckRequest.h"
#include "swift/AST/DiagnosticEngine.h"
#include "swift/Basic/LLVM.h"
#include "llvm/ADT/STLExtras.h"
@@ -54,6 +55,15 @@ class IterativeTypeChecker {
public:
IterativeTypeChecker(TypeChecker &tc) : TC(tc) { }
ASTContext &getASTContext() const;
DiagnosticEngine &getDiags() const;
template<typename ...ArgTypes>
InFlightDiagnostic diagnose(ArgTypes &&...Args) {
return getDiags().diagnose(std::forward<ArgTypes>(Args)...);
}
/// Determine whether the given request has already been satisfied.
bool isSatisfied(TypeCheckRequest request);

View File

@@ -28,6 +28,7 @@ namespace swift {
class ClassDecl;
class EnumDecl;
class ExtensionDecl;
class ProtocolDecl;
class TypeDecl;
/// A request to the type checker to compute some particular kind of

View File

@@ -37,6 +37,7 @@
TYPE_CHECK_REQUEST_PAYLOAD(Class, ClassDecl *)
TYPE_CHECK_REQUEST_PAYLOAD(Enum, EnumDecl *)
TYPE_CHECK_REQUEST_PAYLOAD(InheritedClauseEntry, std::pair<llvm::PointerUnion<TypeDecl *, ExtensionDecl *>, unsigned>)
TYPE_CHECK_REQUEST_PAYLOAD(Protocol, ProtocolDecl *)
/// Perform type checking on an entry in the inherited clause of a
/// type or extension.
@@ -48,5 +49,8 @@ TYPE_CHECK_REQUEST(TypeCheckSuperclass, Class)
/// Perform type checking on the raw type of a particular enum.
TYPE_CHECK_REQUEST(TypeCheckRawType, Enum)
/// Compute the set of inherited protocols for a given protocl
TYPE_CHECK_REQUEST(InheritedProtocols, Protocol)
#undef TYPE_CHECK_REQUEST_PAYLOAD
#undef TYPE_CHECK_REQUEST