Skip to content

Commit 5dd8307

Browse files
committed
AST: Pass SubstOptions to DependentMemberType::substBaseType()
1 parent 6ecaaa4 commit 5dd8307

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

include/swift/AST/Types.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6798,11 +6798,13 @@ class DependentMemberType : public TypeBase {
67986798
/// Substitute the base type, looking up our associated type in it if it is
67996799
/// non-dependent. Returns null if the member could not be found in the new
68006800
/// base.
6801-
Type substBaseType(Type base, LookupConformanceFn lookupConformance);
6801+
Type substBaseType(Type base, LookupConformanceFn lookupConformance,
6802+
SubstOptions options);
68026803

68036804
/// Substitute the root generic type, looking up the chain of associated types.
68046805
/// Returns null if the member could not be found in the new root.
6805-
Type substRootParam(Type newRoot, LookupConformanceFn lookupConformance);
6806+
Type substRootParam(Type newRoot, LookupConformanceFn lookupConformance,
6807+
SubstOptions options);
68066808

68076809
// Implement isa/cast/dyncast/etc.
68086810
static bool classof(const TypeBase *T) {

lib/AST/RequirementMachine/GenericSignatureQueries.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,8 @@ static Type substPrefixType(Type type, unsigned suffixLength, Type prefixType,
346346
auto substBaseType = substPrefixType(memberType->getBase(), suffixLength - 1,
347347
prefixType, sig);
348348
return memberType->substBaseType(substBaseType,
349-
LookUpConformanceInSignature(sig.getPointer()));
349+
LookUpConformanceInSignature(sig.getPointer()),
350+
llvm::None);
350351
}
351352

352353
/// Unlike most other queries, the input type can be any type, not just a

lib/AST/Type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5595,7 +5595,7 @@ TypeBase::getAutoDiffTangentSpace(LookupConformanceFn lookupConformance) {
55955595

55965596
// Try to get the `TangentVector` associated type of `base`.
55975597
// Return the associated type if it is valid.
5598-
auto assocTy = dependentType->substBaseType(this, lookupConformance);
5598+
auto assocTy = dependentType->substBaseType(this, lookupConformance, llvm::None);
55995599
if (!assocTy->hasError())
56005600
return cache(TangentSpace::getTangentVector(assocTy));
56015601

lib/AST/TypeSubstitution.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,30 +274,32 @@ operator()(CanType dependentType, Type conformingReplacementType,
274274
}
275275

276276
Type DependentMemberType::substBaseType(ModuleDecl *module, Type substBase) {
277-
return substBaseType(substBase, LookUpConformanceInModule(module));
277+
return substBaseType(substBase, LookUpConformanceInModule(module), llvm::None);
278278
}
279279

280280
Type DependentMemberType::substBaseType(Type substBase,
281-
LookupConformanceFn lookupConformance) {
281+
LookupConformanceFn lookupConformance,
282+
SubstOptions options) {
282283
if (substBase.getPointer() == getBase().getPointer() &&
283284
substBase->hasTypeParameter())
284285
return this;
285286

286-
InFlightSubstitution IFS(nullptr, lookupConformance, llvm::None);
287+
InFlightSubstitution IFS(nullptr, lookupConformance, options);
287288
return getMemberForBaseType(IFS, getBase(), substBase,
288289
getAssocType(), getName(),
289290
/*level=*/0);
290291
}
291292

292293
Type DependentMemberType::substRootParam(Type newRoot,
293-
LookupConformanceFn lookupConformance){
294+
LookupConformanceFn lookupConformance,
295+
SubstOptions options) {
294296
auto base = getBase();
295297
if (base->is<GenericTypeParamType>()) {
296-
return substBaseType(newRoot, lookupConformance);
298+
return substBaseType(newRoot, lookupConformance, options);
297299
}
298300
if (auto depMem = base->getAs<DependentMemberType>()) {
299-
return substBaseType(depMem->substRootParam(newRoot, lookupConformance),
300-
lookupConformance);
301+
return substBaseType(depMem->substRootParam(newRoot, lookupConformance, options),
302+
lookupConformance, options);
301303
}
302304
return Type();
303305
}

lib/SILGen/ResultPlan.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ mapTypeOutOfOpenedExistentialContext(CanType t) {
136136
if (auto *dmt =
137137
archTy->getInterfaceType()->getAs<DependentMemberType>()) {
138138
return dmt->substRootParam(params[index],
139-
MakeAbstractConformanceForGenericType());
139+
MakeAbstractConformanceForGenericType(),
140+
llvm::None);
140141
}
141142

142143
return params[index];

0 commit comments

Comments
 (0)