@@ -4686,6 +4686,8 @@ isAnyFunctionTypeCanonical(ArrayRef<AnyFunctionType::Param> params,
4686
4686
// For now, generic function types cannot be dependent (in fact,
4687
4687
// they erase dependence) or contain type variables, and they're
4688
4688
// always materializable.
4689
+ // FIXME: This doesn't seem great, we should consider changing it to be opt-out
4690
+ // rather than opt-in.
4689
4691
static RecursiveTypeProperties
4690
4692
getGenericFunctionRecursiveProperties (ArrayRef<AnyFunctionType::Param> params,
4691
4693
Type result, Type globalActor,
@@ -4694,34 +4696,25 @@ getGenericFunctionRecursiveProperties(ArrayRef<AnyFunctionType::Param> params,
4694
4696
" revisit this if you add new recursive type properties" );
4695
4697
RecursiveTypeProperties properties;
4696
4698
4697
- for (auto param : params) {
4698
- if (param.getPlainType ()->getRecursiveProperties ().hasError ())
4699
- properties |= RecursiveTypeProperties::HasError;
4700
- if (param.getPlainType ()->getRecursiveProperties ().isUnsafe ())
4701
- properties |= RecursiveTypeProperties::IsUnsafe;
4702
- }
4699
+ using Prop = RecursiveTypeProperties::Property;
4700
+ auto mask = (unsigned )Prop::HasError | Prop::IsUnsafe | Prop::HasPlaceholder;
4701
+
4702
+ auto unionBits = [&](Type ty) {
4703
+ if (!ty)
4704
+ return ;
4705
+ auto bits = ty->getRecursiveProperties ().getBits ();
4706
+ properties |= Prop (bits & mask);
4707
+ };
4708
+
4709
+ for (auto param : params)
4710
+ unionBits (param.getPlainType ());
4703
4711
4704
4712
if (result->getRecursiveProperties ().hasDynamicSelf ())
4705
4713
properties |= RecursiveTypeProperties::HasDynamicSelf;
4706
- if (result->getRecursiveProperties ().hasError ())
4707
- properties |= RecursiveTypeProperties::HasError;
4708
- if (result->getRecursiveProperties ().isUnsafe ())
4709
- properties |= RecursiveTypeProperties::IsUnsafe;
4710
-
4711
- if (globalActor) {
4712
- if (globalActor->getRecursiveProperties ().hasError ())
4713
- properties |= RecursiveTypeProperties::HasError;
4714
- if (globalActor->getRecursiveProperties ().isUnsafe ())
4715
- properties |= RecursiveTypeProperties::IsUnsafe;
4716
- }
4717
-
4718
- if (thrownError) {
4719
- if (thrownError->getRecursiveProperties ().hasError ())
4720
- properties |= RecursiveTypeProperties::HasError;
4721
- if (thrownError->getRecursiveProperties ().isUnsafe ())
4722
- properties |= RecursiveTypeProperties::IsUnsafe;
4723
- }
4724
4714
4715
+ unionBits (result);
4716
+ unionBits (globalActor);
4717
+ unionBits (thrownError);
4725
4718
return properties;
4726
4719
}
4727
4720
0 commit comments