Skip to content

Commit f674ca9

Browse files
committed
RequirementMachine: Remove the older 'concrete type in domain' hack
1 parent 378231c commit f674ca9

File tree

3 files changed

+0
-62
lines changed

3 files changed

+0
-62
lines changed

lib/AST/RequirementMachine/PropertyMap.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ void PropertyMap::clear() {
304304

305305
Trie.clear();
306306
Entries.clear();
307-
ConcreteTypeInDomainMap.clear();
308307
}
309308

310309
/// Build the property map from all rules of the form T.[p] => T, where
@@ -375,10 +374,6 @@ PropertyMap::buildPropertyMap(unsigned maxIterations,
375374
// Now, check for conflicts between superclass and concrete type rules.
376375
checkConcreteTypeRequirements(inducedRules);
377376

378-
// We collect terms with fully concrete types so that we can re-use them
379-
// to tie off recursion in the next step.
380-
computeConcreteTypeInDomainMap();
381-
382377
// Now, we merge concrete type rules with conformance rules, by adding
383378
// relations between associated type members of type parameters with
384379
// the concrete type witnesses in the concrete type's conformance.

lib/AST/RequirementMachine/PropertyMap.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,6 @@ class PropertyMap {
165165
std::vector<PropertyBag *> Entries;
166166
Trie<PropertyBag *, MatchKind::Longest> Trie;
167167

168-
using ConcreteTypeInDomain = std::pair<CanType, ArrayRef<const ProtocolDecl *>>;
169-
llvm::DenseMap<ConcreteTypeInDomain, Term> ConcreteTypeInDomainMap;
170-
171168
// Building the property map introduces new induced rules, which
172169
// runs another round of Knuth-Bendix completion, which rebuilds the
173170
// property map again.
@@ -235,7 +232,6 @@ class PropertyMap {
235232
void checkConcreteTypeRequirements(
236233
SmallVectorImpl<InducedRule> &inducedRules);
237234

238-
void computeConcreteTypeInDomainMap();
239235
void concretizeNestedTypesFromConcreteParents(
240236
SmallVectorImpl<InducedRule> &inducedRules);
241237

lib/AST/RequirementMachine/PropertyUnification.cpp

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -578,33 +578,6 @@ void PropertyMap::checkConcreteTypeRequirements(
578578
}
579579
}
580580

581-
/// For each fully-concrete type, find the shortest term having that concrete type.
582-
/// This is later used by computeConstraintTermForTypeWitness().
583-
void PropertyMap::computeConcreteTypeInDomainMap() {
584-
for (auto *props : Entries) {
585-
if (!props->isConcreteType())
586-
continue;
587-
588-
auto concreteType = props->ConcreteType->getConcreteType();
589-
if (concreteType->hasTypeParameter())
590-
continue;
591-
592-
assert(props->ConcreteType->getSubstitutions().empty());
593-
594-
auto domain = props->Key.getRootProtocols();
595-
auto concreteTypeKey = std::make_pair(concreteType, domain);
596-
597-
auto found = ConcreteTypeInDomainMap.find(concreteTypeKey);
598-
if (found != ConcreteTypeInDomainMap.end())
599-
continue;
600-
601-
auto inserted = ConcreteTypeInDomainMap.insert(
602-
std::make_pair(concreteTypeKey, props->Key));
603-
assert(inserted.second);
604-
(void) inserted;
605-
}
606-
}
607-
608581
void PropertyMap::concretizeNestedTypesFromConcreteParents(
609582
SmallVectorImpl<InducedRule> &inducedRules) {
610583
for (auto *props : Entries) {
@@ -1003,9 +976,6 @@ MutableTerm PropertyMap::computeConstraintTermForTypeWitness(
1003976
if (requirementKind == RequirementKind::SameType &&
1004977
typeWitnessSymbol.getConcreteType() == concreteType &&
1005978
typeWitnessSymbol.getSubstitutions() == substitutions) {
1006-
// FIXME: ConcreteTypeInDomainMap should support substitutions so
1007-
// that we can remove this.
1008-
1009979
if (Debug.contains(DebugFlags::ConcretizeNestedTypes)) {
1010980
llvm::dbgs() << "^^ Type witness is the same as the concrete type\n";
1011981
}
@@ -1028,29 +998,6 @@ MutableTerm PropertyMap::computeConstraintTermForTypeWitness(
1028998
return result;
1029999
}
10301000

1031-
// If the type witness is completely concrete, try to introduce a
1032-
// same-type requirement with another representative type parameter,
1033-
// if we have one.
1034-
if (!typeWitness->hasTypeParameter()) {
1035-
// Check if we have a shorter representative we can use.
1036-
auto domain = key.getRootProtocols();
1037-
auto concreteTypeKey = std::make_pair(typeWitness, domain);
1038-
1039-
auto found = ConcreteTypeInDomainMap.find(concreteTypeKey);
1040-
if (found != ConcreteTypeInDomainMap.end()) {
1041-
MutableTerm result(found->second);
1042-
if (result != subjectType) {
1043-
if (Debug.contains(DebugFlags::ConcretizeNestedTypes)) {
1044-
llvm::dbgs() << "^^ Type witness can re-use property bag of "
1045-
<< found->second << "\n";
1046-
}
1047-
1048-
// FIXME: Record a rewrite path.
1049-
return result;
1050-
}
1051-
}
1052-
}
1053-
10541001
// Otherwise, add a concrete type requirement for the type witness.
10551002
//
10561003
// Add a rule:

0 commit comments

Comments
 (0)