@@ -1466,8 +1466,9 @@ bool ASTContext::hadError() const {
14661466// / Retrieve the arena from which we should allocate storage for a type.
14671467static AllocationArena getArena (RecursiveTypeProperties properties) {
14681468 bool hasTypeVariable = properties.hasTypeVariable ();
1469- return hasTypeVariable? AllocationArena::ConstraintSolver
1470- : AllocationArena::Permanent;
1469+ bool hasHole = properties.hasTypeHole ();
1470+ return hasTypeVariable || hasHole ? AllocationArena::ConstraintSolver
1471+ : AllocationArena::Permanent;
14711472}
14721473
14731474void ASTContext::addSearchPath (StringRef searchPath, bool isFramework,
@@ -2358,6 +2359,17 @@ Type ErrorType::get(Type originalType) {
23582359 return entry = new (mem) ErrorType (ctx, originalType, properties);
23592360}
23602361
2362+ Type HoleType::get (ASTContext &ctx, OriginatorType originator) {
2363+ assert (originator);
2364+ auto properties = reinterpret_cast <TypeBase *>(originator.getOpaqueValue ())
2365+ ->getRecursiveProperties ();
2366+ properties |= RecursiveTypeProperties::HasTypeHole;
2367+
2368+ auto arena = getArena (properties);
2369+ return new (ctx, arena)
2370+ HoleType (ctx, originator, RecursiveTypeProperties::HasTypeHole);
2371+ }
2372+
23612373BuiltinIntegerType *BuiltinIntegerType::get (BuiltinIntegerWidth BitWidth,
23622374 const ASTContext &C) {
23632375 assert (!BitWidth.isArbitraryWidth ());
@@ -2799,6 +2811,7 @@ ReferenceStorageType *ReferenceStorageType::get(Type T,
27992811 ReferenceOwnership ownership,
28002812 const ASTContext &C) {
28012813 assert (!T->hasTypeVariable ()); // not meaningful in type-checker
2814+ assert (!T->hasHole ());
28022815 switch (optionalityOf (ownership)) {
28032816 case ReferenceOwnershipOptionality::Disallowed:
28042817 assert (!T->getOptionalObjectType () && " optional type is disallowed" );
@@ -2957,7 +2970,7 @@ isFunctionTypeCanonical(ArrayRef<AnyFunctionType::Param> params,
29572970static RecursiveTypeProperties
29582971getGenericFunctionRecursiveProperties (ArrayRef<AnyFunctionType::Param> params,
29592972 Type result) {
2960- static_assert (RecursiveTypeProperties::BitWidth == 11 ,
2973+ static_assert (RecursiveTypeProperties::BitWidth == 12 ,
29612974 " revisit this if you add new recursive type properties" );
29622975 RecursiveTypeProperties properties;
29632976
@@ -3185,6 +3198,7 @@ GenericFunctionType *GenericFunctionType::get(GenericSignature sig,
31853198 ExtInfo info) {
31863199 assert (sig && " no generic signature for generic function type?!" );
31873200 assert (!result->hasTypeVariable ());
3201+ assert (!result->hasHole ());
31883202
31893203 llvm::FoldingSetNodeID id;
31903204 GenericFunctionType::Profile (id, sig, params, result, info);
@@ -3509,7 +3523,7 @@ CanSILFunctionType SILFunctionType::get(
35093523 void *mem = ctx.Allocate (bytes, alignof (SILFunctionType));
35103524
35113525 RecursiveTypeProperties properties;
3512- static_assert (RecursiveTypeProperties::BitWidth == 11 ,
3526+ static_assert (RecursiveTypeProperties::BitWidth == 12 ,
35133527 " revisit this if you add new recursive type properties" );
35143528 for (auto ¶m : params)
35153529 properties |= param.getInterfaceType ()->getRecursiveProperties ();
0 commit comments