Bug 15011 – can override public method with protected method

Status
NEW
Severity
minor
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-09-04T08:26:13Z
Last change time
2024-12-13T18:44:29Z
Assigned to
No Owner
Creator
yosikawa
Moved to GitHub: dmd#19037 →

Comments

Comment #0 by yosikawa — 2015-09-04T08:26:13Z
following code prints 'Foo2' expected result is compile error. DMD32 D Compiler v2.068.0 file main.d: import foo; void main() { Foo1 foo = new Foo2(); foo.bar(); } file foo.d: import std.stdio; class Foo1 { void bar() { writeln("Foo1"); } }; class Foo2 : Foo1 { protected override void bar() { writeln("Foo2"); } };
Comment #1 by andrej.mitrovich — 2015-10-14T16:03:17Z
I'm 99% sure this is a feature, not a bug.
Comment #2 by schveiguy — 2015-10-15T16:03:14Z
I don't think it's a "feature". restrictions that have trivial workarounds don't make a lot of sense. However, I don't know that this is something that is super-concerning.
Comment #3 by robert.schadek — 2024-12-13T18:44:29Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19037 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB