diff --git a/include/swift/AST/ProtocolConformanceRef.h b/include/swift/AST/ProtocolConformanceRef.h index 7972750ab93..1368cff87bf 100644 --- a/include/swift/AST/ProtocolConformanceRef.h +++ b/include/swift/AST/ProtocolConformanceRef.h @@ -20,7 +20,6 @@ #include "llvm/ADT/PointerUnion.h" #include "swift/AST/TypeAlignments.h" #include "swift/AST/Type.h" -#include "swift/AST/ProtocolConformance.h" namespace llvm { class raw_ostream; @@ -28,6 +27,8 @@ namespace llvm { namespace swift { +class ProtocolConformance; + /// A ProtocolConformanceRef is a handle to a protocol conformance which /// may be either concrete or abstract. /// diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 70f5135a6c7..104506289c6 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -28,6 +28,7 @@ #include "swift/AST/LazyResolver.h" #include "swift/AST/ModuleLoader.h" #include "swift/AST/NameLookup.h" +#include "swift/AST/ProtocolConformance.h" #include "swift/AST/RawComment.h" #include "swift/AST/SILLayout.h" #include "swift/AST/TypeCheckerDebugConsumer.h" @@ -3606,6 +3607,36 @@ static NominalTypeDecl *findUnderlyingTypeInModule(ASTContext &ctx, return nullptr; } +bool ForeignRepresentationInfo::isRepresentableAsOptional() const { + switch (getKind()) { + case ForeignRepresentableKind::None: + llvm_unreachable("this type is not representable"); + + case ForeignRepresentableKind::Trivial: + return Storage.getPointer() != 0; + + case ForeignRepresentableKind::Bridged: { + auto KPK_ObjectiveCBridgeable = KnownProtocolKind::ObjectiveCBridgeable; + ProtocolDecl *proto = getConformance()->getProtocol(); + assert(proto->isSpecificProtocol(KPK_ObjectiveCBridgeable) && + "unknown protocol; does it support optional?"); + (void)proto; + (void)KPK_ObjectiveCBridgeable; + + return true; + } + + case ForeignRepresentableKind::BridgedError: + return true; + + case ForeignRepresentableKind::Object: + case ForeignRepresentableKind::StaticBridged: + llvm_unreachable("unexpected kind in ForeignRepresentableCacheEntry"); + } + + llvm_unreachable("Unhandled ForeignRepresentableKind in switch."); +} + ForeignRepresentationInfo ASTContext::getForeignRepresentationInfo(NominalTypeDecl *nominal, ForeignLanguage language, diff --git a/lib/AST/ForeignRepresentationInfo.h b/lib/AST/ForeignRepresentationInfo.h index 7dd06292446..05fdb94719d 100644 --- a/lib/AST/ForeignRepresentationInfo.h +++ b/lib/AST/ForeignRepresentationInfo.h @@ -13,7 +13,6 @@ #ifndef SWIFT_FOREIGNREPRESENTATIONINFO_H #define SWIFT_FOREIGNREPRESENTATIONINFO_H -#include "swift/AST/ProtocolConformance.h" #include "swift/AST/Type.h" #include "swift/Basic/LLVM.h" #include "llvm/ADT/PointerEmbeddedInt.h" @@ -21,6 +20,8 @@ namespace swift { +class ProtocolConformance; + class ForeignRepresentationInfo { using PayloadTy = llvm::PointerEmbeddedInt; @@ -112,35 +113,7 @@ public: } /// Returns true if the optional version of this type is also representable. - bool isRepresentableAsOptional() const { - switch (getKind()) { - case ForeignRepresentableKind::None: - llvm_unreachable("this type is not representable"); - - case ForeignRepresentableKind::Trivial: - return Storage.getPointer() != 0; - - case ForeignRepresentableKind::Bridged: { - auto KPK_ObjectiveCBridgeable = KnownProtocolKind::ObjectiveCBridgeable; - ProtocolDecl *proto = getConformance()->getProtocol(); - assert(proto->isSpecificProtocol(KPK_ObjectiveCBridgeable) && - "unknown protocol; does it support optional?"); - (void)proto; - (void)KPK_ObjectiveCBridgeable; - - return true; - } - - case ForeignRepresentableKind::BridgedError: - return true; - - case ForeignRepresentableKind::Object: - case ForeignRepresentableKind::StaticBridged: - llvm_unreachable("unexpected kind in ForeignRepresentableCacheEntry"); - } - - llvm_unreachable("Unhandled ForeignRepresentableKind in switch."); - } + bool isRepresentableAsOptional() const; }; } // end namespace swift diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 659ad44d56c..e80102800a2 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -23,6 +23,7 @@ #include "swift/AST/GenericEnvironment.h" #include "swift/AST/LazyResolver.h" #include "swift/AST/Module.h" +#include "swift/AST/ProtocolConformance.h" #include "swift/AST/SubstitutionMap.h" #include "swift/AST/TypeLoc.h" #include "llvm/ADT/APFloat.h" diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp index de33fabf1ef..069203a6630 100644 --- a/lib/Sema/CSApply.cpp +++ b/lib/Sema/CSApply.cpp @@ -19,6 +19,7 @@ #include "ConstraintSystem.h" #include "swift/AST/ASTVisitor.h" #include "swift/AST/ASTWalker.h" +#include "swift/AST/ProtocolConformance.h" #include "swift/AST/SubstitutionMap.h" #include "swift/Basic/StringExtras.h" #include "llvm/ADT/APFloat.h" diff --git a/lib/Sema/CSRanking.cpp b/lib/Sema/CSRanking.cpp index 02cc31d708a..d437e0e0c11 100644 --- a/lib/Sema/CSRanking.cpp +++ b/lib/Sema/CSRanking.cpp @@ -15,6 +15,7 @@ // //===----------------------------------------------------------------------===// #include "ConstraintSystem.h" +#include "swift/AST/ProtocolConformance.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/Compiler.h" diff --git a/lib/Sema/CodeSynthesis.cpp b/lib/Sema/CodeSynthesis.cpp index 2756738ce78..dc02e5e5f34 100644 --- a/lib/Sema/CodeSynthesis.cpp +++ b/lib/Sema/CodeSynthesis.cpp @@ -23,6 +23,7 @@ #include "swift/AST/Expr.h" #include "swift/AST/GenericEnvironment.h" #include "swift/AST/ParameterList.h" +#include "swift/AST/ProtocolConformance.h" #include "swift/Basic/Defer.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" diff --git a/lib/Sema/ConstraintSystem.h b/lib/Sema/ConstraintSystem.h index ef5f3860fc1..fadbf85bf38 100644 --- a/lib/Sema/ConstraintSystem.h +++ b/lib/Sema/ConstraintSystem.h @@ -29,7 +29,6 @@ #include "swift/AST/ASTVisitor.h" #include "swift/AST/ASTWalker.h" #include "swift/AST/NameLookup.h" -#include "swift/AST/ProtocolConformance.h" #include "swift/AST/Types.h" #include "swift/AST/TypeCheckerDebugConsumer.h" #include "llvm/ADT/ilist.h" diff --git a/lib/Sema/TypeCheckDecl.cpp b/lib/Sema/TypeCheckDecl.cpp index d324496ef62..46518d4211e 100644 --- a/lib/Sema/TypeCheckDecl.cpp +++ b/lib/Sema/TypeCheckDecl.cpp @@ -30,6 +30,7 @@ #include "swift/AST/GenericSignatureBuilder.h" #include "swift/AST/NameLookup.h" #include "swift/AST/PrettyStackTrace.h" +#include "swift/AST/ProtocolConformance.h" #include "swift/AST/ReferencedNameTracker.h" #include "swift/AST/TypeWalker.h" #include "swift/Basic/Statistic.h" diff --git a/lib/Sema/TypeCheckProtocol.cpp b/lib/Sema/TypeCheckProtocol.cpp index ddf4d8a720c..9896f438e38 100644 --- a/lib/Sema/TypeCheckProtocol.cpp +++ b/lib/Sema/TypeCheckProtocol.cpp @@ -28,6 +28,7 @@ #include "swift/AST/GenericEnvironment.h" #include "swift/AST/GenericSignature.h" #include "swift/AST/NameLookup.h" +#include "swift/AST/ProtocolConformance.h" #include "swift/AST/ReferencedNameTracker.h" #include "swift/AST/TypeMatcher.h" #include "swift/AST/TypeWalker.h"