Skip to content

Commit 34ca1d5

Browse files
committed
[Sema] Look for any problematic import just before diagnosing
1 parent d770075 commit 34ca1d5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/Sema/TypeCheckAccess.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ void AccessControlCheckerBase::checkTypeAccessImpl(
192192
return;
193193

194194
AccessScope problematicAccessScope = AccessScope::getPublic();
195-
ImportAccessLevel problematicImport = llvm::None;
196195

197196
if (type) {
198197
llvm::Optional<AccessScope> typeAccessScope =
@@ -263,8 +262,16 @@ void AccessControlCheckerBase::checkTypeAccessImpl(
263262
const TypeRepr *complainRepr = TypeAccessScopeDiagnoser::findTypeWithScope(
264263
typeRepr, problematicAccessScope, useDC, checkUsableFromInline);
265264

265+
ImportAccessLevel complainImport = llvm::None;
266+
if (complainRepr) {
267+
const ValueDecl *VD =
268+
static_cast<const IdentTypeRepr*>(complainRepr)->getBoundDecl();
269+
assert(VD && "findTypeWithScope should return bound TypeReprs only");
270+
complainImport = VD->getImportAccessFrom(useDC);
271+
}
272+
266273
diagnose(problematicAccessScope, complainRepr, downgradeToWarning,
267-
problematicImport);
274+
complainImport);
268275
}
269276

270277
/// Checks if the access scope of the type described by \p TL is valid for the

0 commit comments

Comments
 (0)