@@ -2364,6 +2364,7 @@ bool FailureDiagnosis::diagnoseGeneralMemberFailure(Constraint *constraint) {
2364
2364
// Since the lookup was allowing inaccessible members, let's check
2365
2365
// if it found anything of that sort, which is easy to diagnose.
2366
2366
bool allUnavailable = !CS->TC .getLangOpts ().DisableAvailabilityChecking ;
2367
+ bool allInaccessible = true ;
2367
2368
for (auto &member : result.ViableCandidates ) {
2368
2369
if (!member.isDecl ()) {
2369
2370
// if there is no declaration, this choice is implicitly available.
@@ -2377,30 +2378,29 @@ bool FailureDiagnosis::diagnoseGeneralMemberFailure(Constraint *constraint) {
2377
2378
allUnavailable = false ;
2378
2379
2379
2380
if (decl->isAccessibleFrom (CS->DC ))
2380
- continue ;
2381
-
2382
- if (auto *CD = dyn_cast<ConstructorDecl>(decl)) {
2383
- CS->TC .diagnose (anchor->getLoc (), diag::init_candidate_inaccessible,
2384
- CD->getResultType (), decl->getFormalAccess ());
2385
- } else {
2386
- CS->TC .diagnose (anchor->getLoc (), diag::candidate_inaccessible,
2387
- decl->getName (), decl->getFormalAccess ());
2388
- }
2381
+ allInaccessible = false ;
2382
+ }
2383
+
2384
+ // If no candidates were accessible, say so.
2385
+ if (allInaccessible && !result.ViableCandidates .empty ()) {
2386
+ CS->TC .diagnose (anchor->getLoc (), diag::all_candidates_inaccessible,
2387
+ memberName);
2389
2388
2390
2389
for (auto &candidate : result.ViableCandidates ) {
2391
2390
if (auto decl = candidate.getDecl ()) {
2392
- CS->TC .diagnose (decl, diag::decl_declared_here, decl->getFullName ());
2391
+ CS->TC .diagnose (decl, diag::note_candidate_inaccessible,
2392
+ decl->getFullName (), decl->getFormalAccess ());
2393
2393
}
2394
2394
}
2395
2395
2396
2396
return true ;
2397
2397
}
2398
2398
2399
- // Diagnose 'super.init', which can only appear inside another initializer,
2400
- // specially.
2401
2399
if (result.UnviableCandidates .empty () && isInitializer &&
2402
2400
!baseObjTy->is <MetatypeType>()) {
2403
2401
if (auto ctorRef = dyn_cast<UnresolvedDotExpr>(expr)) {
2402
+ // Diagnose 'super.init', which can only appear inside another
2403
+ // initializer, specially.
2404
2404
if (isa<SuperRefExpr>(ctorRef->getBase ())) {
2405
2405
diagnose (anchor->getLoc (), diag::super_initializer_not_in_initializer);
2406
2406
return true ;
0 commit comments