@@ -13,6 +13,7 @@ module ddmd.dimport;
1313import core.stdc.string ;
1414import core.stdc.stdio ;
1515
16+ import ddmd.access;
1617import ddmd.arraytypes;
1718import ddmd.declaration;
1819import ddmd.dmodule;
@@ -244,7 +245,7 @@ extern (C++) final class Import : Dsymbol
244245 if (mod)
245246 {
246247 // Modules need a list of each imported module
247- // printf("%s imports %s\n", sc.module .toChars(), mod.toChars());
248+ // printf("%s imports %s\n", sc._module .toChars(), mod.toChars());
248249 sc._module.aimports.push(mod);
249250
250251 if (sc.explicitProtection)
@@ -295,10 +296,15 @@ extern (C++) final class Import : Dsymbol
295296 for (size_t i = 0 ; i < aliasdecls.dim; i++ )
296297 {
297298 AliasDeclaration ad = aliasdecls[i];
298- // printf("\tImport %s alias %s = %s, scope = %p\n", toPrettyChars(), aliases[i].toChars(), names[i].toChars(), ad._scope);
299- if (mod.search(loc, names[i]))
299+ // printf("\tImport %s alias %s = %s, scope = %p\n", toPrettyChars(), aliasdecls[i].toChars(), names[i].toChars(), ad._scope);
300+ Dsymbol importedSymbol = mod.search(loc, names[i]);
301+ if (importedSymbol)
300302 {
301- ad.semantic(sc);
303+ // BUGZILLA 15896 : if symbol is private then it shouldn't be accessed
304+ if (importedSymbol.prot().kind == PROTprivate)
305+ mod.error(loc, " member '%s' is private" , names[i].toChars());
306+ else
307+ ad.semantic(sc);
302308 // If the import declaration is in non-root module,
303309 // analysis of the aliased symbol is deferred.
304310 // Therefore, don't see the ad.aliassym or ad.type here.
@@ -307,7 +313,9 @@ extern (C++) final class Import : Dsymbol
307313 {
308314 Dsymbol s = mod.search_correct(names[i]);
309315 if (s)
316+ {
310317 mod.error(loc, " import '%s' not found, did you mean %s '%s'?" , names[i].toChars(), s.kind(), s.toChars());
318+ }
311319 else
312320 mod.error(loc, " import '%s' not found" , names[i].toChars());
313321 ad.type = Type.terror;
0 commit comments