Skip to content

Commit

Permalink
Merge pull request #353 from yebblies/issue3581
Browse files Browse the repository at this point in the history
Issue 3581 - "private" attribute breaks "override"
  • Loading branch information
WalterBright committed Aug 31, 2011
2 parents ba4da91 + 76e3230 commit 07fccae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/func.c
Expand Up @@ -274,6 +274,9 @@ void FuncDeclaration::semantic(Scope *sc)
if (isAbstract() && !isVirtual())
error("non-virtual functions cannot be abstract");

if (isOverride() && !isVirtual())
error("cannot override a non-virtual function");

if ((f->isConst() || f->isImmutable()) && !isThis())
error("without 'this' cannot be const/immutable");

Expand Down
5 changes: 5 additions & 0 deletions test/fail_compilation/fail3581a.d
@@ -0,0 +1,5 @@

class A { void f() {} }
class B : A { static override void f() {}; }

void main() {}
5 changes: 5 additions & 0 deletions test/fail_compilation/fail3581b.d
@@ -0,0 +1,5 @@

class A { void f() {} }
class B : A { private override void f() {}; }

void main() {}

0 comments on commit 07fccae

Please sign in to comment.