[Issue 23947] New: If a class overloads a method mixing private and public and the last overload is public, the method is always public.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue May 30 14:33:56 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=23947
Issue ID: 23947
Summary: If a class overloads a method mixing private and
public and the last overload is public, the method is
always public.
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: default_357-line at yahoo.de
Consider this code:
--- b.d
struct X { }
struct Y { }
class Class {
private void handle(X x) { }
public void handle(Y y) { }
}
--- a.d
import b;
void main() { Class.init.handle(X.init); }
It compiles, even though handle(X) is private. It correctly errors if the order
of handle() is swapped, and permits calling with Y.init - it only assumes all
methods are public if the last method is public.
Wow.
--
More information about the Digitalmars-d-bugs
mailing list