Fix interface types and type lowering of DynamicSelf so archetypes don't creep in.

Allows us to invoke DynamicSelf methods of generic classes.


Swift SVN r13290
This commit is contained in:
Doug Gregor
2014-02-01 05:12:39 +00:00
parent 4269715437
commit fe2ef0e5c6
5 changed files with 25 additions and 10 deletions

View File

@@ -134,6 +134,7 @@ struct ASTContext::Implementation {
llvm::DenseMap<std::pair<Type, Type>, SubstitutedType *> SubstitutedTypes;
llvm::DenseMap<std::pair<Type, void*>, DependentMemberType *>
DependentMemberTypes;
llvm::DenseMap<Type, DynamicSelfType *> DynamicSelfTypes;
llvm::FoldingSet<EnumType> EnumTypes;
llvm::FoldingSet<StructType> StructTypes;
llvm::FoldingSet<ClassType> ClassTypes;
@@ -170,7 +171,6 @@ struct ASTContext::Implementation {
llvm::FoldingSet<ProtocolCompositionType> ProtocolCompositionTypes;
llvm::FoldingSet<BuiltinVectorType> BuiltinVectorTypes;
llvm::FoldingSet<GenericSignature> GenericSignatures;
llvm::DenseMap<Type, DynamicSelfType *> DynamicSelfTypes;
/// \brief The permanent arena.
Arena Permanent;
@@ -1370,18 +1370,17 @@ ModuleType *ModuleType::get(Module *M) {
}
DynamicSelfType *DynamicSelfType::get(Type selfType, const ASTContext &ctx) {
assert(!selfType->hasTypeVariable() && "Type variable in DynamicSelfType");
auto known = ctx.Impl.DynamicSelfTypes.find(selfType);
if (known != ctx.Impl.DynamicSelfTypes.end())
return known->second;
auto properties = selfType->getRecursiveProperties()
- RecursiveTypeProperties::IsNotMaterializable;
auto arena = getArena(properties);
auto arena = getArena(properties);
auto &dynamicSelfTypes = ctx.Impl.getArena(arena).DynamicSelfTypes;
auto known = dynamicSelfTypes.find(selfType);
if (known != dynamicSelfTypes.end())
return known->second;
auto result = new (ctx, arena) DynamicSelfType(selfType, ctx, properties);
ctx.Impl.DynamicSelfTypes.insert({selfType, result});
dynamicSelfTypes.insert({selfType, result});
return result;
}