D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7203 - Method pointer types differ depending on context
Summary: Method pointer types differ depending on context
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-02 12:23 UTC by Robert Clipsham
Modified: 2012-01-02 21:48 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Robert Clipsham 2012-01-02 12:23:09 UTC
class A {
  void foo() {
    pragma(msg, typeof(&A.foo).stringof);
  }
}
pragma(msg, typeof(&A.foo).stringof);

This produces:
----
void function()
void delegate()
----

However it should produce void function() in both cases.
Comment 1 Kenji Hara 2012-01-02 21:48:08 UTC
In non-static member function of A, A.foo is implicitly translated to this.foo.
So in function foo, typeof(&A.foo) == typeof(this.foo) and it is delegate type.

class A {
  void foo() {
    A.foo();  // recursive call
  }
}