@@ -123,7 +123,7 @@ static Type getStdlibType(TypeChecker &TC, Type &cached, DeclContext *dc,
123123 TC.Context .getIdentifier (
124124 name));
125125 if (lookup)
126- cached = lookup.back ().second ;
126+ cached = lookup.back ().MemberType ;
127127 }
128128 return cached;
129129}
@@ -203,7 +203,7 @@ static Type getObjectiveCNominalType(TypeChecker &TC,
203203 if (auto result = TC.lookupMemberType (dc, ModuleType::get (module ), TypeName,
204204 lookupOptions)) {
205205 for (auto pair : result) {
206- if (auto nominal = dyn_cast<NominalTypeDecl>(pair.first )) {
206+ if (auto nominal = dyn_cast<NominalTypeDecl>(pair.Member )) {
207207 cache = nominal->getDeclaredType ();
208208 return cache;
209209 }
@@ -934,14 +934,14 @@ static Type diagnoseUnknownType(TypeChecker &tc, DeclContext *dc,
934934 relookupOptions);
935935 if (inaccessibleMembers) {
936936 // FIXME: What if the unviable candidates have different levels of access?
937- const TypeDecl *first = inaccessibleMembers.front ().first ;
937+ const TypeDecl *first = inaccessibleMembers.front ().Member ;
938938 tc.diagnose (comp->getIdLoc (), diag::candidate_inaccessible,
939939 comp->getIdentifier (), first->getFormalAccess ());
940940
941941 // FIXME: If any of the candidates (usually just one) are in the same module
942942 // we could offer a fix-it.
943943 for (auto lookupResult : inaccessibleMembers)
944- tc.diagnose (lookupResult.first , diag::kind_declared_here,
944+ tc.diagnose (lookupResult.Member , diag::kind_declared_here,
945945 DescriptiveDeclKind::Type);
946946
947947 // Don't try to recover here; we'll get more access-related diagnostics
@@ -1254,7 +1254,8 @@ static Type resolveNestedIdentTypeComponent(
12541254 bool diagnoseErrors,
12551255 GenericTypeResolver *resolver,
12561256 UnsatisfiedDependency *unsatisfiedDependency) {
1257- auto maybeDiagnoseBadMemberType = [&](TypeDecl *member, Type memberType) {
1257+ auto maybeDiagnoseBadMemberType = [&](TypeDecl *member, Type memberType,
1258+ AssociatedTypeDecl *inferredAssocType) {
12581259 // Diagnose invalid cases.
12591260 if (TC.isUnsupportedMemberTypeAccess (parentTy, member)) {
12601261 if (diagnoseErrors) {
@@ -1285,20 +1286,21 @@ static Type resolveNestedIdentTypeComponent(
12851286 }
12861287 }
12871288
1289+ // Diagnose a bad conformance reference if we need to.
1290+ if (inferredAssocType && diagnoseErrors && memberType &&
1291+ memberType->hasError ()) {
1292+ maybeDiagnoseBadConformanceRef (TC, DC, parentTy, comp->getLoc (),
1293+ inferredAssocType);
1294+ }
1295+
12881296 // If we found a reference to an associated type or other member type that
12891297 // was marked invalid, just return ErrorType to silence downstream errors.
12901298 if (member->isInvalid ())
12911299 return ErrorType::get (TC.Context );
12921300
1293- // Diagnose a bad conformance reference if we need to.
1294- if (isa<AssociatedTypeDecl>(member) && diagnoseErrors &&
1295- memberType && memberType->hasError ()) {
1296- maybeDiagnoseBadConformanceRef (TC, DC, parentTy, comp->getLoc (),
1297- cast<AssociatedTypeDecl>(member));
1298- }
1299-
13001301 // At this point, we need to have resolved the type of the member.
1301- if (!memberType || memberType->hasError ()) return memberType;
1302+ if (!memberType || memberType->hasError ())
1303+ return memberType;
13021304
13031305 // If there are generic arguments, apply them now.
13041306 if (!options.contains (TypeResolutionFlags::ResolveStructure)) {
@@ -1335,7 +1337,7 @@ static Type resolveNestedIdentTypeComponent(
13351337 if (auto *typeDecl = comp->getBoundDecl ()) {
13361338 auto memberType = TC.substMemberTypeWithBase (DC->getParentModule (),
13371339 typeDecl, parentTy);
1338- return maybeDiagnoseBadMemberType (typeDecl, memberType);
1340+ return maybeDiagnoseBadMemberType (typeDecl, memberType, nullptr );
13391341 }
13401342
13411343 // Phase 1: Find and bind the component decl.
@@ -1390,6 +1392,7 @@ static Type resolveNestedIdentTypeComponent(
13901392 // If we didn't find anything, complain.
13911393 Type memberType;
13921394 TypeDecl *member = nullptr ;
1395+ AssociatedTypeDecl *inferredAssocType = nullptr ;
13931396 if (!memberTypes) {
13941397 // If we're not allowed to complain or we couldn't fix the
13951398 // source, bail out.
@@ -1403,12 +1406,13 @@ static Type resolveNestedIdentTypeComponent(
14031406 if (!member)
14041407 return ErrorType::get (TC.Context );
14051408 } else {
1406- memberType = memberTypes.back ().second ;
1407- member = memberTypes.back ().first ;
1409+ memberType = memberTypes.back ().MemberType ;
1410+ member = memberTypes.back ().Member ;
1411+ inferredAssocType = memberTypes.back ().InferredAssociatedType ;
14081412 comp->setValue (member, nullptr );
14091413 }
14101414
1411- return maybeDiagnoseBadMemberType (member, memberType);
1415+ return maybeDiagnoseBadMemberType (member, memberType, inferredAssocType );
14121416}
14131417
14141418static Type resolveIdentTypeComponent (
0 commit comments