AST: Move mapType{In,OutOf}Context() out of ArchetypeBuilder and clean up headers

- The DeclContext versions of these methods have equivalents
  on the DeclContext class; use them instead.

- The GenericEnvironment versions of these methods are now
  static methods on the GenericEnvironment class. Note that
  these are not made redundant by the instance methods on
  GenericEnvironment, since the static methods can also be
  called with a null GenericEnvironment, in which case they
  just assert that the type is fully concrete.

- Remove some unnecessary #includes of ArchetypeBuilder.h
  and GenericEnvironment.h. Now changes to these files
  result in a lot less recompilation.
This commit is contained in:
Slava Pestov
2016-12-18 18:52:32 -08:00
parent ad45e0be41
commit fb0f372e94
56 changed files with 287 additions and 349 deletions

View File

@@ -16,6 +16,7 @@
#include "swift/AST/GenericEnvironment.h"
#include "swift/AST/ASTContext.h"
#include "swift/AST/ArchetypeBuilder.h"
#include "swift/AST/ProtocolConformance.h"
using namespace swift;
@@ -162,6 +163,28 @@ bool GenericEnvironment::containsPrimaryArchetype(
QueryArchetypeToInterfaceSubstitutions(this)(archetype));
}
Type GenericEnvironment::mapTypeIntoContext(ModuleDecl *M,
GenericEnvironment *env,
Type type) {
assert(!type->hasArchetype() && "already have a contextual type");
if (!env)
return type.substDependentTypesWithErrorTypes();
return env->mapTypeIntoContext(M, type);
}
Type
GenericEnvironment::mapTypeOutOfContext(GenericEnvironment *env,
Type type) {
assert(!type->hasTypeParameter() && "already have an interface type");
if (!env)
return type.substDependentTypesWithErrorTypes();
return env->mapTypeOutOfContext(type);
}
Type GenericEnvironment::mapTypeOutOfContext(Type type) const {
type = type.subst(QueryArchetypeToInterfaceSubstitutions(this),
MakeAbstractConformanceForGenericType(),