3333// ===----------------------------------------------------------------------===//
3434
3535#include " swift/AST/ASTContext.h"
36+ #include " swift/AST/ConformanceLookup.h"
3637#include " swift/AST/Decl.h"
3738#include " swift/AST/GenericEnvironment.h"
3839#include " swift/AST/GenericSignature.h"
@@ -332,6 +333,8 @@ bool RequirementMachine::isReducedType(Type type) const {
332333// / Given a type parameter 'T.A1.A2...An', a suffix length m where m <= n,
333334// / and a replacement type U, produce the type 'U.A(n-m)...An' by replacing
334335// / 'T.A1...A(n-m-1)' with 'U'.
336+ // /
337+ // / FIXME: Remove this.
335338static Type substPrefixType (Type type, unsigned suffixLength, Type prefixType,
336339 GenericSignature sig) {
337340 if (suffixLength == 0 )
@@ -340,9 +343,12 @@ static Type substPrefixType(Type type, unsigned suffixLength, Type prefixType,
340343 auto *memberType = type->castTo <DependentMemberType>();
341344 auto substBaseType = substPrefixType (memberType->getBase (), suffixLength - 1 ,
342345 prefixType, sig);
343- return memberType->substBaseType (
344- substBaseType, LookUpConformanceInModule (),
345- std::nullopt );
346+ auto *assocDecl = memberType->getAssocType ();
347+ auto *proto = assocDecl->getProtocol ();
348+ auto conformance = lookupConformance (substBaseType, proto);
349+ return conformance.getAssociatedType (
350+ substBaseType,
351+ assocDecl->getDeclaredInterfaceType ());
346352}
347353
348354Type RequirementMachine::getReducedTypeParameter (
@@ -380,6 +386,8 @@ Type RequirementMachine::getReducedTypeParameter(
380386 //
381387 // Note that V can be empty if T is fully valid; we expect this to be
382388 // true most of the time.
389+ //
390+ // FIXME: Remove all of this.
383391 auto prefix = getLongestValidPrefix (term);
384392
385393 // Get a type (concrete or dependent) for U.
0 commit comments