mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
AST: Add ExistentialLayout::getSuperclass(), rename superclass to explicitSuperclass
More groundwork for protocols with superclass constraints. In several places we need to distinguish between existential types that have a superclass term (MyClass & Proto) and existential types containing a protocol with a superclass constraint. This is similar to how I can write 'AnyObject & Proto', or write 'Proto1 & Proto2' where Proto1 has an ': AnyObject' in its inheritance clause. Note that some of the usages will be revisited later as I do more refactoring and testing. This is just a first pass.
This commit is contained in:
@@ -1387,10 +1387,10 @@ ConstraintSystem::matchExistentialTypes(Type type1, Type type2,
|
||||
}
|
||||
}
|
||||
|
||||
if (layout.superclass) {
|
||||
if (layout.explicitSuperclass) {
|
||||
auto subKind = std::min(ConstraintKind::Subtype, kind);
|
||||
auto result = matchTypes(type1, layout.superclass, subKind, subflags,
|
||||
locator);
|
||||
auto result = matchTypes(type1, layout.explicitSuperclass, subKind,
|
||||
subflags, locator);
|
||||
if (result.isFailure())
|
||||
return result;
|
||||
}
|
||||
@@ -1398,6 +1398,14 @@ ConstraintSystem::matchExistentialTypes(Type type1, Type type2,
|
||||
for (auto *proto : layout.getProtocols()) {
|
||||
auto *protoDecl = proto->getDecl();
|
||||
|
||||
if (auto superclass = protoDecl->getSuperclass()) {
|
||||
auto subKind = std::min(ConstraintKind::Subtype, kind);
|
||||
auto result = matchTypes(type1, superclass, subKind,
|
||||
subflags, locator);
|
||||
if (result.isFailure())
|
||||
return result;
|
||||
}
|
||||
|
||||
switch (simplifyConformsToConstraint(type1, protoDecl, kind, locator,
|
||||
subflags)) {
|
||||
case SolutionKind::Solved:
|
||||
|
||||
Reference in New Issue
Block a user