29
29
#include " swift/AST/GenericEnvironment.h"
30
30
#include " swift/AST/LazyResolver.h"
31
31
#include " swift/AST/Module.h"
32
+ #include " swift/AST/PackConformance.h"
32
33
#include " swift/AST/ParameterList.h"
33
34
#include " swift/AST/ProtocolConformance.h"
34
35
#include " swift/AST/SILLayout.h"
@@ -4365,10 +4366,6 @@ static Type getMemberForBaseType(LookupConformanceFn lookupConformances,
4365
4366
4366
4367
// Retrieve the member type with the given name.
4367
4368
4368
- // Tuples don't have member types.
4369
- if (substBase->is <TupleType>())
4370
- return failed ();
4371
-
4372
4369
// If we know the associated type, look in the witness table.
4373
4370
if (assocType) {
4374
4371
auto proto = assocType->getProtocol ();
@@ -4377,30 +4374,37 @@ static Type getMemberForBaseType(LookupConformanceFn lookupConformances,
4377
4374
4378
4375
if (conformance.isInvalid ())
4379
4376
return failed ();
4380
- if (!conformance.isConcrete ())
4381
- return failed ();
4382
-
4383
- // Retrieve the type witness.
4384
- auto witness =
4385
- conformance.getConcrete ()->getTypeWitnessAndDecl (assocType, options);
4386
-
4387
- auto witnessTy = witness.getWitnessType ();
4388
- if (!witnessTy || witnessTy->hasError ())
4389
- return failed ();
4390
4377
4391
- // This is a hacky feature allowing code completion to migrate to
4392
- // using Type::subst() without changing output.
4393
- if (options & SubstFlags::DesugarMemberTypes) {
4394
- if (auto *aliasType = dyn_cast<TypeAliasType>(witnessTy.getPointer ()))
4395
- witnessTy = aliasType->getSinglyDesugaredType ();
4378
+ Type witnessTy;
4396
4379
4397
- // Another hack. If the type witness is a opaque result type. They can
4398
- // only be referred using the name of the associated type.
4399
- if (witnessTy->is <OpaqueTypeArchetypeType>())
4400
- witnessTy = witness.getWitnessDecl ()->getDeclaredInterfaceType ();
4380
+ // Retrieve the type witness.
4381
+ if (conformance.isPack ()) {
4382
+ auto *packConformance = conformance.getPack ();
4383
+
4384
+ witnessTy = packConformance->getAssociatedType (
4385
+ assocType->getDeclaredInterfaceType ());
4386
+ } else if (conformance.isConcrete ()) {
4387
+ auto witness =
4388
+ conformance.getConcrete ()->getTypeWitnessAndDecl (assocType, options);
4389
+
4390
+ witnessTy = witness.getWitnessType ();
4391
+ if (!witnessTy || witnessTy->hasError ())
4392
+ return failed ();
4393
+
4394
+ // This is a hacky feature allowing code completion to migrate to
4395
+ // using Type::subst() without changing output.
4396
+ if (options & SubstFlags::DesugarMemberTypes) {
4397
+ if (auto *aliasType = dyn_cast<TypeAliasType>(witnessTy.getPointer ()))
4398
+ witnessTy = aliasType->getSinglyDesugaredType ();
4399
+
4400
+ // Another hack. If the type witness is a opaque result type. They can
4401
+ // only be referred using the name of the associated type.
4402
+ if (witnessTy->is <OpaqueTypeArchetypeType>())
4403
+ witnessTy = witness.getWitnessDecl ()->getDeclaredInterfaceType ();
4404
+ }
4401
4405
}
4402
4406
4403
- if (witnessTy->is <ErrorType>())
4407
+ if (!witnessTy || witnessTy->is <ErrorType>())
4404
4408
return failed ();
4405
4409
4406
4410
return witnessTy;
0 commit comments