Skip to content

Commit 27ea1d5

Browse files
committed
[NFC] TypeResolution: Nuke TypeResolutionStage::Contextual
1 parent c97221f commit 27ea1d5

File tree

6 files changed

+6
-42
lines changed

6 files changed

+6
-42
lines changed

include/swift/AST/TypeResolutionStage.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ enum class TypeResolutionStage : uint8_t {
3131
/// Produces a complete interface type where all member references have been
3232
/// resolved.
3333
Interface,
34-
35-
/// Produces a contextual type involving archetypes within the context of
36-
/// the type.
37-
Contextual,
3834
};
3935

4036
/// Display a type resolution stage.

lib/AST/TypeCheckRequests.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ void swift::simple_display(llvm::raw_ostream &out,
5858
case TypeResolutionStage::Interface:
5959
out << "interface";
6060
break;
61-
62-
case TypeResolutionStage::Contextual:
63-
out << "contextual";
64-
break;
6561
}
6662
}
6763

lib/Sema/TypeCheckGeneric.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -965,9 +965,6 @@ RequirementRequest::evaluate(Evaluator &evaluator,
965965
/*unboundTyOpener*/ nullptr,
966966
/*placeholderHandler*/ nullptr);
967967
break;
968-
969-
case TypeResolutionStage::Contextual:
970-
llvm_unreachable("No clients care about this. Use mapTypeIntoContext()");
971968
}
972969

973970
auto &reqRepr = getRequirement();

lib/Sema/TypeCheckRequestFunctions.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,6 @@ Type InheritedTypeRequest::evaluate(
5656
/*unboundTyOpener*/ nullptr,
5757
/*placeholderHandler*/ nullptr);
5858
break;
59-
60-
case TypeResolutionStage::Contextual: {
61-
// Compute the contextual type by mapping the interface type into context.
62-
auto result =
63-
evaluator(InheritedTypeRequest{decl, index,
64-
TypeResolutionStage::Interface});
65-
if (!result)
66-
return Type();
67-
68-
return dc->mapTypeIntoContext(*result);
69-
}
7059
}
7160

7261
const TypeLoc &typeLoc = getInheritedTypeLocAtIndex(decl, index);

lib/Sema/TypeCheckType.cpp

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ ASTContext &TypeResolution::getASTContext() const {
9999

100100
GenericSignature TypeResolution::getGenericSignature() const {
101101
assert(
102-
stage > TypeResolutionStage::Structural &&
102+
stage == TypeResolutionStage::Interface &&
103103
"Structural resolution shouldn't require generic signature computation");
104104

105105
if (genericEnv)
@@ -134,9 +134,6 @@ Type TypeResolution::resolveDependentMemberType(
134134
case TypeResolutionStage::Interface:
135135
// Handled below.
136136
break;
137-
138-
case TypeResolutionStage::Contextual:
139-
llvm_unreachable("Use TypeResolution::resolveContextualType instead");
140137
}
141138

142139
assert(stage == TypeResolutionStage::Interface);
@@ -233,9 +230,6 @@ Type TypeResolution::resolveSelfAssociatedType(Type baseTy,
233230
case TypeResolutionStage::Interface:
234231
// Handled below.
235232
break;
236-
237-
case TypeResolutionStage::Contextual:
238-
llvm_unreachable("Use TypeResolution::resolveContextualType instead");
239233
}
240234

241235
assert(stage == TypeResolutionStage::Interface);
@@ -274,17 +268,9 @@ bool TypeResolution::areSameType(Type type1, Type type2) const {
274268
if (type1->isEqual(type2))
275269
return true;
276270

277-
switch (stage) {
278-
case TypeResolutionStage::Structural:
279-
case TypeResolutionStage::Interface:
280-
// If neither type has a type parameter, we're done.
281-
if (!type1->hasTypeParameter() && !type2->hasTypeParameter())
282-
return false;
283-
284-
break;
285-
286-
case TypeResolutionStage::Contextual:
287-
llvm_unreachable("Use TypeResolution::resolveContextualType instead");
271+
// If neither type has a type parameter, we're done.
272+
if (!type1->hasTypeParameter() && !type2->hasTypeParameter()) {
273+
return false;
288274
}
289275

290276
if (stage == TypeResolutionStage::Interface) {
@@ -855,7 +841,7 @@ Type TypeResolution::applyUnboundGenericArguments(
855841
// generic signature.
856842
auto *module = getDeclContext()->getParentModule();
857843

858-
if (!skipRequirementsCheck && getStage() > TypeResolutionStage::Structural) {
844+
if (!skipRequirementsCheck && getStage() == TypeResolutionStage::Interface) {
859845
// Check the generic arguments against the requirements of the declaration's
860846
// generic signature.
861847

lib/Sema/TypeChecker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ TypeChecker::getDeclTypeCheckingSemantics(ValueDecl *decl) {
502502
bool TypeChecker::isDifferentiable(Type type, bool tangentVectorEqualsSelf,
503503
DeclContext *dc,
504504
Optional<TypeResolutionStage> stage) {
505-
if (stage && stage != TypeResolutionStage::Contextual)
505+
if (stage)
506506
type = dc->mapTypeIntoContext(type);
507507
auto tanSpace = type->getAutoDiffTangentSpace(
508508
LookUpConformanceInModule(dc->getParentModule()));

0 commit comments

Comments
 (0)