Bug 15983 – [REG 2.071] Symbol visibility in derived classes

Status
RESOLVED
Resolution
DUPLICATE
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-05-02T09:43:00Z
Last change time
2016-09-12T03:36:35Z
Assigned to
code
Creator
renezwanenburg

Comments

Comment #0 by renezwanenburg — 2016-05-02T09:43:40Z
This is probably the same issue as 15897, only no circular imports are involved: --- module a; class Base { private alias Something = int; } void foo(T : Base)(T t) { T.Something something; } --- module b; import a; class Derived : Base {} void main() { foo(new Derived()); } --- This fails to compile with the message a.d(10): Error: no property 'Something' for type 'b.Derived'. In this case the fix is easy enough: just use Base.Something in foo(). But my actual code involves a templated base class and template mixin which make that unfeasible.
Comment #1 by code — 2016-09-12T03:36:35Z
You can get the base class like so. void foo(T)(T t) if (is(T Base == super)) { Base.Something something; } Still need to have all base classes in a the same module/package as the function. Would be interested to know, why you rely on duck typing of the base class. Also maybe it's not worth to hide Something when it's a common property of your class hierarchy. *** This issue has been marked as a duplicate of issue 15897 ***