Skip to content

Commit 2905274

Browse files
committed
[Type checker] Eliminate ProtocolRequirementTypeResolver.
This generic type resolver is now equivalent to the DependentGenericTypeResolver. Use that instead.
1 parent afc916e commit 2905274

File tree

4 files changed

+3
-48
lines changed

4 files changed

+3
-48
lines changed

lib/Sema/GenericTypeResolver.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -103,24 +103,6 @@ class GenericTypeToArchetypeResolver : public GenericTypeResolver {
103103
virtual bool areSameType(Type type1, Type type2);
104104
};
105105

106-
/// Generic type resolver that only handles what can appear in a protocol
107-
/// definition, i.e. Self, and Self.A.B.C dependent types.
108-
///
109-
/// This should only be used when resolving/validating where clauses in
110-
/// protocols.
111-
class ProtocolRequirementTypeResolver : public GenericTypeResolver {
112-
public:
113-
virtual bool usesArchetypes() { return false; }
114-
115-
virtual Type mapTypeIntoContext(Type type);
116-
117-
virtual Type resolveDependentMemberType(Type baseTy, DeclContext *DC,
118-
SourceRange baseRange,
119-
ComponentIdentTypeRepr *ref);
120-
121-
virtual bool areSameType(Type type1, Type type2);
122-
};
123-
124106
/// Generic type resolver that performs complete resolution of dependent
125107
/// types based on a given generic signature builder.
126108
///

lib/Sema/TypeCheckDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class DenseMapInfo<RawValueKey> {
208208
static void validateAttributes(TypeChecker &TC, Decl *D);
209209

210210
void TypeChecker::resolveTrailingWhereClause(ProtocolDecl *proto) {
211-
ProtocolRequirementTypeResolver resolver;
211+
DependentGenericTypeResolver resolver;
212212
validateWhereClauses(proto, &resolver);
213213
}
214214

@@ -4488,7 +4488,7 @@ void TypeChecker::validateDeclForNameLookup(ValueDecl *D) {
44884488
auto helper = [&] {
44894489
(void) typealias->getFormalAccess();
44904490

4491-
ProtocolRequirementTypeResolver resolver;
4491+
DependentGenericTypeResolver resolver;
44924492
TypeResolutionOptions options(TypeResolverContext::TypeAliasDecl);
44934493
if (validateType(typealias->getUnderlyingTypeLoc(),
44944494
typealias, options, &resolver)) {

lib/Sema/TypeCheckGeneric.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -75,33 +75,6 @@ bool GenericTypeToArchetypeResolver::areSameType(Type type1, Type type2) {
7575
return type1->isEqual(type2);
7676
}
7777

78-
Type ProtocolRequirementTypeResolver::mapTypeIntoContext(Type type) {
79-
return type;
80-
}
81-
82-
Type ProtocolRequirementTypeResolver::resolveDependentMemberType(
83-
Type baseTy, DeclContext *DC, SourceRange baseRange,
84-
ComponentIdentTypeRepr *ref) {
85-
return DependentMemberType::get(baseTy, ref->getIdentifier());
86-
}
87-
88-
bool ProtocolRequirementTypeResolver::areSameType(Type type1, Type type2) {
89-
if (type1->isEqual(type2))
90-
return true;
91-
92-
// If both refer to associated types with the same name, they'll implicitly
93-
// be considered equivalent.
94-
auto depMem1 = type1->getAs<DependentMemberType>();
95-
if (!depMem1) return false;
96-
97-
auto depMem2 = type2->getAs<DependentMemberType>();
98-
if (!depMem2) return false;
99-
100-
if (depMem1->getName() != depMem2->getName()) return false;
101-
102-
return areSameType(depMem1->getBase(), depMem2->getBase());
103-
}
104-
10578
CompleteGenericTypeResolver::CompleteGenericTypeResolver(
10679
TypeChecker &tc,
10780
GenericSignature *genericSig)

lib/Sema/TypeCheckRequestFunctions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ InheritedTypeRequest::evaluate(
4040
options |= TypeResolutionFlags::AllowUnavailableProtocol;
4141
}
4242

43-
ProtocolRequirementTypeResolver protoResolver;
43+
DependentGenericTypeResolver protoResolver;
4444
GenericTypeToArchetypeResolver archetypeResolver(dc);
4545
GenericTypeResolver *resolver;
4646
if (isa<ProtocolDecl>(dc)) {

0 commit comments

Comments
 (0)