@@ -3897,7 +3897,9 @@ get(GenericTypeDecl *TheDecl, Type Parent, const ASTContext &C) {
38973897 UnboundGenericType::Profile (ID, TheDecl, Parent);
38983898 void *InsertPos = nullptr ;
38993899 RecursiveTypeProperties properties;
3900+ if (TheDecl->isUnsafe ()) properties |= RecursiveTypeProperties::IsUnsafe;
39003901 if (Parent) properties |= Parent->getRecursiveProperties ();
3902+
39013903 auto arena = getArena (properties);
39023904
39033905 if (auto unbound = C.getImpl ().getArena (arena).UnboundGenericTypes
@@ -3948,6 +3950,7 @@ BoundGenericType *BoundGenericType::get(NominalTypeDecl *TheDecl,
39483950 llvm::FoldingSetNodeID ID;
39493951 BoundGenericType::Profile (ID, TheDecl, Parent, GenericArgs);
39503952 RecursiveTypeProperties properties;
3953+ if (TheDecl->isUnsafe ()) properties |= RecursiveTypeProperties::IsUnsafe;
39513954 if (Parent) properties |= Parent->getRecursiveProperties ();
39523955 for (Type Arg : GenericArgs) {
39533956 properties |= Arg->getRecursiveProperties ();
@@ -4029,6 +4032,7 @@ EnumType::EnumType(EnumDecl *TheDecl, Type Parent, const ASTContext &C,
40294032
40304033EnumType *EnumType::get (EnumDecl *D, Type Parent, const ASTContext &C) {
40314034 RecursiveTypeProperties properties;
4035+ if (D->isUnsafe ()) properties |= RecursiveTypeProperties::IsUnsafe;
40324036 if (Parent) properties |= Parent->getRecursiveProperties ();
40334037 auto arena = getArena (properties);
40344038
@@ -4045,6 +4049,7 @@ StructType::StructType(StructDecl *TheDecl, Type Parent, const ASTContext &C,
40454049
40464050StructType *StructType::get (StructDecl *D, Type Parent, const ASTContext &C) {
40474051 RecursiveTypeProperties properties;
4052+ if (D->isUnsafe ()) properties |= RecursiveTypeProperties::IsUnsafe;
40484053 if (Parent) properties |= Parent->getRecursiveProperties ();
40494054 auto arena = getArena (properties);
40504055
@@ -4061,6 +4066,7 @@ ClassType::ClassType(ClassDecl *TheDecl, Type Parent, const ASTContext &C,
40614066
40624067ClassType *ClassType::get (ClassDecl *D, Type Parent, const ASTContext &C) {
40634068 RecursiveTypeProperties properties;
4069+ if (D->isUnsafe ()) properties |= RecursiveTypeProperties::IsUnsafe;
40644070 if (Parent) properties |= Parent->getRecursiveProperties ();
40654071 auto arena = getArena (properties);
40664072
@@ -4325,20 +4331,39 @@ isAnyFunctionTypeCanonical(ArrayRef<AnyFunctionType::Param> params,
43254331// always materializable.
43264332static RecursiveTypeProperties
43274333getGenericFunctionRecursiveProperties (ArrayRef<AnyFunctionType::Param> params,
4328- Type result) {
4329- static_assert (RecursiveTypeProperties::BitWidth == 18 ,
4334+ Type result, Type globalActor,
4335+ Type thrownError) {
4336+ static_assert (RecursiveTypeProperties::BitWidth == 19 ,
43304337 " revisit this if you add new recursive type properties" );
43314338 RecursiveTypeProperties properties;
43324339
43334340 for (auto param : params) {
43344341 if (param.getPlainType ()->getRecursiveProperties ().hasError ())
43354342 properties |= RecursiveTypeProperties::HasError;
4343+ if (param.getPlainType ()->getRecursiveProperties ().isUnsafe ())
4344+ properties |= RecursiveTypeProperties::IsUnsafe;
43364345 }
43374346
43384347 if (result->getRecursiveProperties ().hasDynamicSelf ())
43394348 properties |= RecursiveTypeProperties::HasDynamicSelf;
43404349 if (result->getRecursiveProperties ().hasError ())
43414350 properties |= RecursiveTypeProperties::HasError;
4351+ if (result->getRecursiveProperties ().isUnsafe ())
4352+ properties |= RecursiveTypeProperties::IsUnsafe;
4353+
4354+ if (globalActor) {
4355+ if (globalActor->getRecursiveProperties ().hasError ())
4356+ properties |= RecursiveTypeProperties::HasError;
4357+ if (globalActor->getRecursiveProperties ().isUnsafe ())
4358+ properties |= RecursiveTypeProperties::IsUnsafe;
4359+ }
4360+
4361+ if (thrownError) {
4362+ if (thrownError->getRecursiveProperties ().hasError ())
4363+ properties |= RecursiveTypeProperties::HasError;
4364+ if (thrownError->getRecursiveProperties ().isUnsafe ())
4365+ properties |= RecursiveTypeProperties::IsUnsafe;
4366+ }
43424367
43434368 return properties;
43444369}
@@ -4671,7 +4696,8 @@ GenericFunctionType *GenericFunctionType::get(GenericSignature sig,
46714696 hasLifetimeDependenceInfo ? numLifetimeDependencies : 0 );
46724697 void *mem = ctx.Allocate (allocSize, alignof (GenericFunctionType));
46734698
4674- auto properties = getGenericFunctionRecursiveProperties (params, result);
4699+ auto properties = getGenericFunctionRecursiveProperties (
4700+ params, result, globalActor, thrownError);
46754701 auto funcTy = new (mem) GenericFunctionType (sig, params, result, info,
46764702 isCanonical ? &ctx : nullptr ,
46774703 properties);
@@ -5044,7 +5070,7 @@ CanSILFunctionType SILFunctionType::get(
50445070 void *mem = ctx.Allocate (bytes, alignof (SILFunctionType));
50455071
50465072 RecursiveTypeProperties properties;
5047- static_assert (RecursiveTypeProperties::BitWidth == 18 ,
5073+ static_assert (RecursiveTypeProperties::BitWidth == 19 ,
50485074 " revisit this if you add new recursive type properties" );
50495075 for (auto ¶m : params)
50505076 properties |= param.getInterfaceType ()->getRecursiveProperties ();
@@ -5132,6 +5158,7 @@ OptionalType *OptionalType::get(Type base) {
51325158ProtocolType *ProtocolType::get (ProtocolDecl *D, Type Parent,
51335159 const ASTContext &C) {
51345160 RecursiveTypeProperties properties;
5161+ if (D->isUnsafe ()) properties |= RecursiveTypeProperties::IsUnsafe;
51355162 if (Parent) properties |= Parent->getRecursiveProperties ();
51365163 auto arena = getArena (properties);
51375164
0 commit comments