digitalmars.D.bugs - [Issue 20277] New: Template this parameters are not respected in
- d-bugmail puremagic.com (50/50) Oct 07 2019 https://issues.dlang.org/show_bug.cgi?id=20277
https://issues.dlang.org/show_bug.cgi?id=20277 Issue ID: 20277 Summary: Template this parameters are not respected in static context Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: maxsamukha gmail.com class A { void foo(this T)() { } static void bar(this T)() { } template baz(this T) { static void baz() { } } } class B : A { } void main() { B b; b.foo(); // ok B.bar(); //fail b.bar(); // fail b.baz(); // ok B.baz(); // fail } onlineapp.d(22): Error: template onlineapp.A.bar cannot deduce function from argument types !()(), candidates are: onlineapp.d(5): bar(this T)() onlineapp.d(23): Error: template onlineapp.A.bar cannot deduce function from argument types !()(), candidates are: onlineapp.d(5): bar(this T)() onlineapp.d(26): Error: template onlineapp.A.baz cannot deduce function from argument types !()(), candidates are: onlineapp.d(8): baz(this T)() run.dlang.io: https://run.dlang.io/is/Hme9vp Accessing the static type of a class in the context of a base class is an extremely useful feature, and there is no reason to restrict it to just non-static functions, precluding valid use cases like factory function generation etc. --
Oct 07 2019