Bug 18951 – package static method masked by public static method in class

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-06-06T09:19:27Z
Last change time
2018-06-08T11:48:06Z
Keywords
pull
Assigned to
No Owner
Creator
FeepingCreature

Comments

Comment #0 by default_357-line — 2018-06-06T09:19:27Z
This issue arises as a result of the fix for issue 12511. test/A.d: module test.A; public class Class { package static void foo(Object) {} public static void foo() {} } test/B.d: import test.A; void main() { Class.foo(new Object); } test/B.d(4): Error: function test.A.Class.foo() is not callable using argument types (Object) What happens is that the 12511 fix pulls up the public foo() because it's the most visible foo in Class. package foo, which is also perfectly visible from test.B, has a lower visibility and is thus ignored.
Comment #1 by slavo5150 — 2018-06-06T13:37:43Z
Comment #2 by github-bugzilla — 2018-06-08T11:48:05Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/3c8788053d0fab4195ad442df184ddfc33065f1a Fix Issue 18951. When selecting the "most-visible" overload method to check access, treat package methods as public if they're visible; otherwise, private. This avoids package methods that are perfectly visible being passed over in favor of public (numerically more visible) overloads appearing later in the class. https://github.com/dlang/dmd/commit/5f3b12bcda64046712d7fdb89772cbad63fdc79b Merge pull request #8338 from FeepingCreature/fix/Issue_18951 Fix Issue 18951 - package static method masked by public static method in class merged-on-behalf-of: Razvan Nitu <[email protected]>