Skip to content

Commit 4f3d05f

Browse files
committed
RequirementMachine: Remove Symbol::getSuperclass()
1 parent 1539128 commit 4f3d05f

File tree

6 files changed

+14
-23
lines changed

6 files changed

+14
-23
lines changed

lib/AST/RequirementMachine/PropertyMap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ Type PropertyBag::getSuperclassBound(
154154
const MutableTerm &lookupTerm,
155155
const PropertyMap &map) const {
156156
MutableTerm prefix = getPrefixAfterStrippingKey(lookupTerm);
157-
return map.getTypeFromSubstitutionSchema(Superclass->getSuperclass(),
157+
return map.getTypeFromSubstitutionSchema(Superclass->getConcreteType(),
158158
Superclass->getSubstitutions(),
159159
genericParams, prefix);
160160
}

lib/AST/RequirementMachine/PropertyMap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class PropertyBag {
106106
}
107107

108108
CanType getSuperclassBound() const {
109-
return Superclass->getSuperclass();
109+
return Superclass->getConcreteType();
110110
}
111111

112112
Type getSuperclassBound(

lib/AST/RequirementMachine/PropertyUnification.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ static std::pair<Symbol, bool> unifySuperclasses(
312312
llvm::dbgs() << "% Unifying " << lhs << " with " << rhs << "\n";
313313
}
314314

315-
auto lhsType = lhs.getSuperclass();
316-
auto rhsType = rhs.getSuperclass();
315+
auto lhsType = lhs.getConcreteType();
316+
auto rhsType = rhs.getConcreteType();
317317

318318
auto *lhsClass = lhsType.getClassOrBoundGenericClass();
319319
assert(lhsClass != nullptr);
@@ -425,7 +425,7 @@ void PropertyMap::addProperty(
425425
// A rule (T.[superclass: C] => T) induces a rule (T.[layout: L] => T),
426426
// where L is either AnyObject or _NativeObject.
427427
auto superclass =
428-
property.getSuperclass()->getClassOrBoundGenericClass();
428+
property.getConcreteType()->getClassOrBoundGenericClass();
429429
auto layout =
430430
LayoutConstraint::getLayoutConstraint(
431431
superclass->getLayoutConstraintKind(),
@@ -579,7 +579,7 @@ void PropertyMap::concretizeNestedTypesFromConcreteParents() {
579579
props->getKey(),
580580
RequirementKind::Superclass,
581581
*props->SuperclassRule,
582-
props->Superclass->getSuperclass(),
582+
props->Superclass->getConcreteType(),
583583
props->Superclass->getSubstitutions(),
584584
props->ConformsToRules,
585585
props->ConformsTo,

lib/AST/RequirementMachine/RequirementMachineRequests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ RequirementMachine::buildRequirementsFromRules(
126126
// For compatibility with the old GenericSignatureBuilder, drop requirements
127127
// containing ErrorTypes.
128128
auto superclassType = Map.getTypeFromSubstitutionSchema(
129-
prop->getSuperclass(),
129+
prop->getConcreteType(),
130130
prop->getSubstitutions(),
131131
genericParams, MutableTerm());
132132
if (superclassType->hasError())

lib/AST/RequirementMachine/Symbol.cpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,11 @@ LayoutConstraint Symbol::getLayoutConstraint() const {
198198
return Ptr->Layout;
199199
}
200200

201-
/// Get the superclass type associated with a superclass symbol.
202-
CanType Symbol::getSuperclass() const {
203-
assert(getKind() == Kind::Superclass);
204-
return Ptr->ConcreteType;
205-
}
206-
207-
/// Get the concrete type associated with a concrete type symbol.
201+
/// Get the concrete type associated with a superclass, concrete type or
202+
/// concrete conformance symbol.
208203
CanType Symbol::getConcreteType() const {
209-
assert(getKind() == Kind::ConcreteType ||
204+
assert(getKind() == Kind::Superclass ||
205+
getKind() == Kind::ConcreteType ||
210206
getKind() == Kind::ConcreteConformance);
211207
return Ptr->ConcreteType;
212208
}
@@ -635,10 +631,7 @@ int Symbol::compare(Symbol other, RewriteContext &ctx) const {
635631

636632
case Kind::Superclass:
637633
case Kind::ConcreteType: {
638-
if (kind == Kind::Superclass
639-
? (getSuperclass() == other.getSuperclass())
640-
: (getConcreteType() == other.getConcreteType())) {
641-
634+
if (getConcreteType() == other.getConcreteType()) {
642635
// If the concrete types are identical, compare substitution terms.
643636
assert(getSubstitutions().size() == other.getSubstitutions().size());
644637
for (unsigned i : indices(getSubstitutions())) {
@@ -676,7 +669,7 @@ Symbol Symbol::withConcreteSubstitutions(
676669
RewriteContext &ctx) const {
677670
switch (getKind()) {
678671
case Kind::Superclass:
679-
return Symbol::forSuperclass(getSuperclass(), substitutions, ctx);
672+
return Symbol::forSuperclass(getConcreteType(), substitutions, ctx);
680673

681674
case Kind::ConcreteType:
682675
return Symbol::forConcreteType(getConcreteType(), substitutions, ctx);
@@ -787,7 +780,7 @@ void Symbol::dump(llvm::raw_ostream &out) const {
787780
return;
788781

789782
case Kind::Superclass:
790-
out << "[superclass: " << getSuperclass();
783+
out << "[superclass: " << getConcreteType();
791784
dumpSubstitutions();
792785
out << "]";
793786
return;

lib/AST/RequirementMachine/Symbol.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,6 @@ class Symbol final {
175175

176176
LayoutConstraint getLayoutConstraint() const;
177177

178-
CanType getSuperclass() const;
179-
180178
CanType getConcreteType() const;
181179

182180
ArrayRef<Term> getSubstitutions() const;

0 commit comments

Comments
 (0)