Skip to content

Commit e197455

Browse files
authored
Merge pull request swiftlang#40936 from slavapestov/rqm-new-term-to-type-mapping
RequirementMachine: Redo term to type mapping
2 parents 68c4586 + 275af8d commit e197455

File tree

11 files changed

+631
-459
lines changed

11 files changed

+631
-459
lines changed

lib/AST/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ add_swift_host_library(swiftAST STATIC
7676
RequirementEnvironment.cpp
7777
RequirementMachine/GenericSignatureQueries.cpp
7878
RequirementMachine/HomotopyReduction.cpp
79+
RequirementMachine/InterfaceType.cpp
7980
RequirementMachine/KnuthBendix.cpp
8081
RequirementMachine/MinimalConformances.cpp
8182
RequirementMachine/PropertyMap.cpp

lib/AST/RequirementMachine/GenericSignatureQueries.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ RequirementMachine::getLocalRequirements(
3838
verify(term);
3939

4040
GenericSignature::LocalRequirements result;
41-
result.anchor = Context.getTypeForTerm(term, genericParams);
41+
result.anchor = Map.getTypeForTerm(term, genericParams);
4242

4343
auto *props = Map.lookUpProperties(term);
4444
if (!props)
4545
return result;
4646

4747
if (props->isConcreteType()) {
48-
result.concreteType = props->getConcreteType({}, term, Context);
48+
result.concreteType = props->getConcreteType({}, term, Map);
4949
return result;
5050
}
5151

5252
if (props->hasSuperclassBound()) {
53-
result.superclass = props->getSuperclassBound({}, term, Context);
53+
result.superclass = props->getSuperclassBound({}, term, Map);
5454
}
5555

5656
for (const auto *proto : props->getConformsToExcludingSuperclassConformances())
@@ -152,7 +152,7 @@ getSuperclassBound(Type depType,
152152
if (!props->hasSuperclassBound())
153153
return Type();
154154

155-
return props->getSuperclassBound(genericParams, term, Context);
155+
return props->getSuperclassBound(genericParams, term, Map);
156156
}
157157

158158
bool RequirementMachine::isConcreteType(Type depType) const {
@@ -183,7 +183,7 @@ getConcreteType(Type depType,
183183
if (!props->isConcreteType())
184184
return Type();
185185

186-
return props->getConcreteType(genericParams, term, Context);
186+
return props->getConcreteType(genericParams, term, Map);
187187
}
188188

189189
bool RequirementMachine::areSameTypeParameterInContext(Type depType1,
@@ -277,7 +277,7 @@ bool RequirementMachine::isCanonicalTypeInContext(Type type) const {
277277
Self.System.simplify(term);
278278
Self.verify(term);
279279

280-
auto anchor = Self.Context.getTypeForTerm(term, {});
280+
auto anchor = Self.Map.getTypeForTerm(term, {});
281281
if (CanType(anchor) != CanType(component))
282282
return Action::Stop;
283283

@@ -353,7 +353,7 @@ Type RequirementMachine::getCanonicalTypeInContext(
353353
if (props) {
354354
if (props->isConcreteType()) {
355355
auto concreteType = props->getConcreteType(genericParams,
356-
prefix, Context);
356+
prefix, Map);
357357
if (!concreteType->hasTypeParameter())
358358
return concreteType;
359359

@@ -368,7 +368,7 @@ Type RequirementMachine::getCanonicalTypeInContext(
368368
if (props->hasSuperclassBound() &&
369369
prefix.size() != term.size()) {
370370
auto superclass = props->getSuperclassBound(genericParams,
371-
prefix, Context);
371+
prefix, Map);
372372
if (!superclass->hasTypeParameter())
373373
return superclass;
374374

@@ -377,7 +377,7 @@ Type RequirementMachine::getCanonicalTypeInContext(
377377
}
378378
}
379379

380-
return Context.getTypeForTerm(prefix, genericParams);
380+
return Map.getTypeForTerm(prefix, genericParams);
381381
}();
382382

383383
// If T is already valid, the longest valid prefix U of T is T itself, and
@@ -402,7 +402,7 @@ Type RequirementMachine::getCanonicalTypeInContext(
402402

403403
// Compute the type of the unresolved suffix term V, rooted in the
404404
// generic parameter τ_0_0.
405-
auto origType = Context.getRelativeTypeForTerm(term, prefix);
405+
auto origType = Map.getRelativeTypeForTerm(term, prefix);
406406

407407
// Substitute τ_0_0 in the above relative type with the concrete type
408408
// for U.

0 commit comments

Comments
 (0)