Skip to content

Commit 5e1acf5

Browse files
committed
[AST] Preserve HasPlaceholder recursive property for GenericFunctionType
1 parent 78ea361 commit 5e1acf5

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

lib/AST/ASTContext.cpp

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4686,6 +4686,8 @@ isAnyFunctionTypeCanonical(ArrayRef<AnyFunctionType::Param> params,
46864686
// For now, generic function types cannot be dependent (in fact,
46874687
// they erase dependence) or contain type variables, and they're
46884688
// always materializable.
4689+
// FIXME: This doesn't seem great, we should consider changing it to be opt-out
4690+
// rather than opt-in.
46894691
static RecursiveTypeProperties
46904692
getGenericFunctionRecursiveProperties(ArrayRef<AnyFunctionType::Param> params,
46914693
Type result, Type globalActor,
@@ -4694,34 +4696,25 @@ getGenericFunctionRecursiveProperties(ArrayRef<AnyFunctionType::Param> params,
46944696
"revisit this if you add new recursive type properties");
46954697
RecursiveTypeProperties properties;
46964698

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());
47034711

47044712
if (result->getRecursiveProperties().hasDynamicSelf())
47054713
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-
}
47244714

4715+
unionBits(result);
4716+
unionBits(globalActor);
4717+
unionBits(thrownError);
47254718
return properties;
47264719
}
47274720

0 commit comments

Comments
 (0)