mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
AST: Introduce primitive AnyObject type
Add a 'hasExplicitAnyObject()' bit to ProtocolCompositionType to represent canonical composition types containing '& AnyObject'. Serialize this bit and take it into account when building ExistentialLayouts. Rename ProtocolCompositionType::getProtocols() to getMembers() since it can contain classes now, and update a few usages that need further attention with FIXMEs or asserts. For now, nothing actually constructs these types, and they will trigger arounds asserts. Upcoming patches will introduce support for this.
This commit is contained in:
@@ -2199,13 +2199,16 @@ static ConstraintResult visitInherited(
|
||||
// Local function that (recursively) adds inherited types.
|
||||
ConstraintResult result = ConstraintResult::Resolved;
|
||||
std::function<void(Type, const TypeRepr *)> visitInherited;
|
||||
|
||||
// FIXME: Should this whole thing use getExistentialLayout() instead?
|
||||
|
||||
visitInherited = [&](Type inheritedType, const TypeRepr *typeRepr) {
|
||||
// Decompose protocol compositions.
|
||||
auto composition = dyn_cast_or_null<CompositionTypeRepr>(typeRepr);
|
||||
if (auto compositionType
|
||||
= inheritedType->getAs<ProtocolCompositionType>()) {
|
||||
unsigned index = 0;
|
||||
for (auto protoType : compositionType->getProtocols()) {
|
||||
for (auto protoType : compositionType->getMembers()) {
|
||||
if (composition && index < composition->getTypes().size())
|
||||
visitInherited(protoType, composition->getTypes()[index]);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user