Bug 2855 – __traits: no way to get overloads and information for non-instance methods

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2009-04-18T21:20:17Z
Last change time
2018-04-20T07:19:06Z
Keywords
patch
Assigned to
Walter Bright
Creator
Neia Neutuladh

Attachments

IDFilenameSummaryContent-TypeSize
327traits.patchpatch to add traits for dealing with static methodstext/plain1989
328traits.patchfixed patchtext/plain2031
329tests.dtest casestext/plain1238
331traits.patchattempt 3text/plain3158

Comments

Comment #0 by dhasenan — 2009-04-18T21:20:17Z
Given a UDT and a constructor or a static method, I want to use __traits to access overloads of that constructor or static method. __traits provides allMembers, which returns static and non-static functions and non-static constructors. It also provides getVirtualFunctions, which provides overloads for non-static functions. There is no equivalent to getVirtualFunctions for constructors or static functions.
Comment #1 by dhasenan — 2009-04-19T10:43:42Z
Created attachment 327 patch to add traits for dealing with static methods
Comment #2 by dhasenan — 2009-04-19T10:45:27Z
This patch adds traits: isStaticFunction getStaticFunctions getOverloads This doesn't handle constructors, but it does handle static functions.
Comment #3 by dhasenan — 2009-04-19T11:22:56Z
Created attachment 328 fixed patch
Comment #4 by dhasenan — 2009-04-19T11:25:17Z
Created attachment 329 test cases I don't know what the preferred format is for the DMD test suite. (Hint hint.) So I did something reasonable.
Comment #5 by dhasenan — 2009-04-20T19:21:36Z
Created attachment 331 attempt 3 HA HA DISREGARD THAT, I CAN'T DIFF (But thankfully, git can.)
Comment #6 by dhasenan — 2009-04-21T18:35:30Z
In point of fact, this does handle constructors: __traits(getOverloads, T, "__ctor")
Comment #7 by simen.kjaras — 2018-04-20T07:19:06Z
Current DMD handles all cases in this issue, and has for a long time. getStaticFunctions is not in DMD, but can easily be implemented in a library.