Skip to content

Commit 951086a

Browse files
committed
Sema: Remove ModuleDecl parameter from substMemberTypeWithBase()
1 parent 98e13d2 commit 951086a

File tree

5 files changed

+9
-15
lines changed

5 files changed

+9
-15
lines changed

lib/Sema/AssociatedTypeInference.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ static ResolveWitnessResult resolveTypeWitnessViaLookup(
517517
}
518518

519519
auto memberType = TypeChecker::substMemberTypeWithBase(
520-
dc->getParentModule(), typeDecl, dc->getSelfInterfaceType());
520+
typeDecl, dc->getSelfInterfaceType());
521521

522522
// Type witnesses that resolve to constraint types are always
523523
// existential types. This can only happen when the type witness

lib/Sema/ConstraintSystem.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2723,8 +2723,7 @@ DeclReferenceType ConstraintSystem::getTypeOfMemberReference(
27232723
if (auto *typeDecl = dyn_cast<TypeDecl>(value)) {
27242724
assert(!isa<ModuleDecl>(typeDecl) && "Nested module?");
27252725

2726-
auto memberTy = TypeChecker::substMemberTypeWithBase(DC->getParentModule(),
2727-
typeDecl, baseObjTy);
2726+
auto memberTy = TypeChecker::substMemberTypeWithBase(typeDecl, baseObjTy);
27282727

27292728
// If the member type is a constraint, e.g. because the
27302729
// reference is to a typealias with an underlying protocol

lib/Sema/TypeCheckNameLookup.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,7 @@ LookupTypeResult TypeChecker::lookupMemberType(DeclContext *dc,
475475
}
476476

477477
// Substitute the base into the member's type.
478-
auto memberType = substMemberTypeWithBase(dc->getParentModule(),
479-
typeDecl, type);
478+
auto memberType = substMemberTypeWithBase(typeDecl, type);
480479

481480
// If we haven't seen this type result yet, add it to the result set.
482481
if (types.insert(memberType->getCanonicalType()).second)
@@ -516,7 +515,7 @@ LookupTypeResult TypeChecker::lookupMemberType(DeclContext *dc,
516515
continue;
517516

518517
auto memberType =
519-
substMemberTypeWithBase(dc->getParentModule(), typeDecl, type);
518+
substMemberTypeWithBase(typeDecl, type);
520519
if (types.insert(memberType->getCanonicalType()).second)
521520
result.addResult({typeDecl, memberType, assocType});
522521
}

lib/Sema/TypeCheckType.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,7 @@ Type TypeResolution::resolveDependentMemberType(
310310
}
311311
}
312312

313-
return TypeChecker::substMemberTypeWithBase(DC->getParentModule(), concrete,
314-
baseTy);
313+
return TypeChecker::substMemberTypeWithBase(concrete, baseTy);
315314
}
316315

317316
bool TypeResolution::areSameType(Type type1, Type type2) const {
@@ -580,7 +579,7 @@ Type TypeResolution::resolveTypeInContext(TypeDecl *typeDecl,
580579

581580
// Finally, substitute the base type into the member type.
582581
return TypeChecker::substMemberTypeWithBase(
583-
fromDC->getParentModule(), typeDecl, selfType, /*useArchetypes=*/false);
582+
typeDecl, selfType, /*useArchetypes=*/false);
584583
}
585584

586585
/// This function checks if a bound generic type is UnsafePointer<Void> or
@@ -1872,8 +1871,7 @@ static Type resolveQualifiedIdentTypeRepr(const TypeResolution &resolution,
18721871
// Phase 2: If a declaration has already been bound, use it.
18731872
if (auto *typeDecl = repr->getBoundDecl()) {
18741873
auto memberType =
1875-
TypeChecker::substMemberTypeWithBase(DC->getParentModule(), typeDecl,
1876-
parentTy);
1874+
TypeChecker::substMemberTypeWithBase(typeDecl, parentTy);
18771875
return maybeDiagnoseBadMemberType(typeDecl, memberType, nullptr);
18781876
}
18791877

@@ -5796,8 +5794,7 @@ NeverNullType TypeResolver::buildProtocolType(
57965794
return MetatypeType::get(instanceType, storedRepr);
57975795
}
57985796

5799-
Type TypeChecker::substMemberTypeWithBase(ModuleDecl *module,
5800-
TypeDecl *member,
5797+
Type TypeChecker::substMemberTypeWithBase(TypeDecl *member,
58015798
Type baseTy,
58025799
bool useArchetypes) {
58035800
Type sugaredBaseTy = baseTy;

lib/Sema/TypeChecker.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,12 @@ void checkExistentialTypes(ASTContext &ctx,
322322
/// Substitute the given base type into the type of the given nested type,
323323
/// producing the effective type that the nested type will have.
324324
///
325-
/// \param module The module in which the substitution will be performed.
326325
/// \param member The member whose type projection is being computed.
327326
/// \param baseTy The base type that will be substituted for the 'Self' of the
328327
/// member.
329328
/// \param useArchetypes Whether to use context archetypes for outer generic
330329
/// parameters if the class is nested inside a generic function.
331-
Type substMemberTypeWithBase(ModuleDecl *module, TypeDecl *member, Type baseTy,
330+
Type substMemberTypeWithBase(TypeDecl *member, Type baseTy,
332331
bool useArchetypes = true);
333332

334333
/// Determine whether this is a "pass-through" typealias, which has the

0 commit comments

Comments
 (0)