mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #40282 from hborla/existential-any
[SE-0335] Introduce existential `any`
This commit is contained in:
@@ -408,6 +408,7 @@ struct ASTContext::Implementation {
|
||||
llvm::DenseMap<std::pair<StructDecl*, Type>, StructType*> StructTypes;
|
||||
llvm::DenseMap<std::pair<ClassDecl*, Type>, ClassType*> ClassTypes;
|
||||
llvm::DenseMap<std::pair<ProtocolDecl*, Type>, ProtocolType*> ProtocolTypes;
|
||||
llvm::DenseMap<Type, ExistentialType *> ExistentialTypes;
|
||||
llvm::FoldingSet<UnboundGenericType> UnboundGenericTypes;
|
||||
llvm::FoldingSet<BoundGenericType> BoundGenericTypes;
|
||||
llvm::FoldingSet<ProtocolCompositionType> ProtocolCompositionTypes;
|
||||
@@ -4113,6 +4114,21 @@ ProtocolType::ProtocolType(ProtocolDecl *TheDecl, Type Parent,
|
||||
RecursiveTypeProperties properties)
|
||||
: NominalType(TypeKind::Protocol, &Ctx, TheDecl, Parent, properties) { }
|
||||
|
||||
ExistentialType *ExistentialType::get(Type constraint) {
|
||||
auto properties = constraint->getRecursiveProperties();
|
||||
auto arena = getArena(properties);
|
||||
|
||||
auto &C = constraint->getASTContext();
|
||||
auto &entry = C.getImpl().getArena(arena).ExistentialTypes[constraint];
|
||||
if (entry)
|
||||
return entry;
|
||||
|
||||
const ASTContext *canonicalContext = constraint->isCanonical() ? &C : nullptr;
|
||||
return entry = new (C, arena) ExistentialType(constraint,
|
||||
canonicalContext,
|
||||
properties);
|
||||
}
|
||||
|
||||
LValueType *LValueType::get(Type objectTy) {
|
||||
assert(!objectTy->is<LValueType>() && !objectTy->is<InOutType>() &&
|
||||
"cannot have 'inout' or @lvalue wrapped inside an @lvalue");
|
||||
|
||||
Reference in New Issue
Block a user