Skip to content

Commit

Permalink
fix Issue 15897 - private base class method not seen through derived …
Browse files Browse the repository at this point in the history
…class

- properly deprecate private symbol visibility through derived classes
  • Loading branch information
MartinNowak committed May 4, 2016
1 parent c5a5758 commit b6dba31
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/mtype.d
Original file line number Diff line number Diff line change
Expand Up @@ -8670,12 +8670,18 @@ public:
Dsymbol sold = void;
if (global.params.bug10378 || global.params.check10378)
{
sold = sym.search(e.loc, ident, flags);
sold = sym.search(e.loc, ident, flags | IgnoreSymbolVisibility);
if (!global.params.check10378)
return sold;
}

auto s = sym.search(e.loc, ident, flags | SearchLocalsOnly);
if (!s)
{
s = sym.search(e.loc, ident, flags | SearchLocalsOnly | IgnoreSymbolVisibility);
if (s && !(flags & IgnoreErrors))
.deprecation(e.loc, "%s is not visible from class %s", s.toPrettyChars(), sym.toChars());
}
if (global.params.check10378)
{
alias snew = s;
Expand Down
6 changes: 6 additions & 0 deletions test/fail_compilation/imports/test15897.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module imports.test15897;
import test15897;

class Cat : Animal
{
}
19 changes: 19 additions & 0 deletions test/fail_compilation/test15897.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// REQUIRED_ARGS: -de
/*
TEST_OUTPUT:
---
fail_compilation/test15897.d(18): Deprecation: test15897.Animal.create is not visible from class Cat
---
*/
module test15897;
import imports.test15897;

class Animal
{
private void create() {}
}

void foo(Cat cat)
{
cat.create();
}

0 comments on commit b6dba31

Please sign in to comment.