[AST] Stop including GenericSignature.h in other headers.

Except GenericEnvironment.h, because you can't meaningfully use a
GenericEnvironment without its signature. Lots less depends on
GenericSignature.h now. NFC
This commit is contained in:
Doug Gregor
2017-10-12 13:30:53 -07:00
parent bec95b2caa
commit cd3c63cbfd
30 changed files with 105 additions and 58 deletions

View File

@@ -19,6 +19,7 @@
#include "swift/SIL/TypeLowering.h"
#include "swift/AST/ASTContext.h"
#include "swift/AST/Decl.h"
#include "swift/AST/GenericSignature.h"
#include "swift/AST/ForeignErrorConvention.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
@@ -182,6 +183,35 @@ AbstractionPattern::getOptional(AbstractionPattern object,
llvm_unreachable("bad kind");
}
bool AbstractionPattern::isConcreteType() const {
assert(isTypeParameter());
return (getKind() != Kind::Opaque &&
GenericSig != nullptr &&
GenericSig->isConcreteType(getType()));
}
bool AbstractionPattern::requiresClass() {
switch (getKind()) {
case Kind::Opaque:
return false;
case Kind::Type:
case Kind::Discard: {
auto type = getType();
if (auto archetype = dyn_cast<ArchetypeType>(type))
return archetype->requiresClass();
else if (isa<DependentMemberType>(type) ||
isa<GenericTypeParamType>(type)) {
assert(GenericSig &&
"Dependent type in pattern without generic signature?");
return GenericSig->requiresClass(type);
}
return false;
}
default:
return false;
}
}
bool AbstractionPattern::matchesTuple(CanTupleType substType) {
switch (getKind()) {
case Kind::Invalid: