[Issue 20277] New: Template this parameters are not respected in static context
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Oct 7 11:48:45 UTC 2019
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 at puremagic.com
Reporter: maxsamukha at 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.
--
More information about the Digitalmars-d-bugs
mailing list