@@ -3380,7 +3380,7 @@ StringRef swift::getSwiftName(KnownFoundationEntity kind) {
33803380// ===----------------------------------------------------------------------===//
33813381
33823382TypeAliasType::TypeAliasType (TypeAliasDecl *typealias, Type parent,
3383- SubstitutionMap substitutions ,
3383+ ArrayRef<Type> genericArgs ,
33843384 Type underlying,
33853385 RecursiveTypeProperties properties)
33863386 : SugarType(TypeKind::TypeAlias, underlying, properties),
@@ -3393,35 +3393,41 @@ TypeAliasType::TypeAliasType(TypeAliasDecl *typealias, Type parent,
33933393 Bits.TypeAliasType .HasParent = false ;
33943394 }
33953395
3396- // Record the substitutions.
3397- if (substitutions) {
3398- assert (typealias->getGenericSignature ()->isEqual (
3399- substitutions.getGenericSignature ()));
3400- Bits.TypeAliasType .HasSubstitutionMap = true ;
3401- *getTrailingObjects<SubstitutionMap>() = substitutions;
3396+ auto *params = typealias->getGenericParams ();
3397+ unsigned count = genericArgs.size ();
3398+
3399+ // Record the generic arguments.
3400+ if (count > 0 ) {
3401+ ASSERT (params->size () == count);
3402+ Bits.TypeAliasType .GenericArgCount = count;
3403+ std::uninitialized_copy (genericArgs.begin (), genericArgs.end (),
3404+ getTrailingObjects<Type>() +
3405+ (parent ? 1 : 0 ));
34023406 } else {
3403- assert (!typealias-> isGenericContext () );
3404- Bits.TypeAliasType .HasSubstitutionMap = false ;
3407+ ASSERT (params == nullptr );
3408+ Bits.TypeAliasType .GenericArgCount = 0 ;
34053409 }
34063410}
34073411
34083412TypeAliasType *TypeAliasType::get (TypeAliasDecl *typealias, Type parent,
3409- SubstitutionMap substitutions ,
3413+ ArrayRef<Type> genericArgs ,
34103414 Type underlying) {
34113415 // Compute the recursive properties.
34123416 //
34133417 auto properties = underlying->getRecursiveProperties ();
34143418 if (parent)
34153419 properties |= parent->getRecursiveProperties ();
3416- properties |= substitutions.getRecursiveProperties ();
3420+
3421+ for (auto arg : genericArgs)
3422+ properties |= arg->getRecursiveProperties ();
34173423
34183424 // Figure out which arena this type will go into.
34193425 auto &ctx = underlying->getASTContext ();
34203426 auto arena = getArena (properties);
34213427
34223428 // Profile the type.
34233429 llvm::FoldingSetNodeID id;
3424- TypeAliasType::Profile (id, typealias, parent, substitutions , underlying);
3430+ TypeAliasType::Profile (id, typealias, parent, genericArgs , underlying);
34253431
34263432 // Did we already record this type?
34273433 void *insertPos;
@@ -3430,29 +3436,29 @@ TypeAliasType *TypeAliasType::get(TypeAliasDecl *typealias, Type parent,
34303436 return result;
34313437
34323438 // Build a new type.
3433- auto genericSig = substitutions.getGenericSignature ();
3434- auto size = totalSizeToAlloc<Type, SubstitutionMap>(parent ? 1 : 0 ,
3435- genericSig ? 1 : 0 );
3439+ auto size = totalSizeToAlloc<Type>((parent ? 1 : 0 ) + genericArgs.size ());
34363440 auto mem = ctx.Allocate (size, alignof (TypeAliasType), arena);
3437- auto result = new (mem) TypeAliasType (typealias, parent, substitutions ,
3441+ auto result = new (mem) TypeAliasType (typealias, parent, genericArgs ,
34383442 underlying, properties);
34393443 types.InsertNode (result, insertPos);
34403444 return result;
34413445}
34423446
34433447void TypeAliasType::Profile (llvm::FoldingSetNodeID &id) const {
3444- Profile (id, getDecl (), getParent (), getSubstitutionMap (),
3448+ Profile (id, getDecl (), getParent (), getDirectGenericArgs (),
34453449 Type (getSinglyDesugaredType ()));
34463450}
34473451
34483452void TypeAliasType::Profile (
34493453 llvm::FoldingSetNodeID &id,
34503454 TypeAliasDecl *typealias,
3451- Type parent, SubstitutionMap substitutions ,
3455+ Type parent, ArrayRef<Type> genericArgs ,
34523456 Type underlying) {
34533457 id.AddPointer (typealias);
34543458 id.AddPointer (parent.getPointer ());
3455- substitutions.profile (id);
3459+ id.AddInteger (genericArgs.size ());
3460+ for (auto arg : genericArgs)
3461+ id.AddPointer (arg.getPointer ());
34563462 id.AddPointer (underlying.getPointer ());
34573463}
34583464
0 commit comments