Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fix Issue 1918 - __traits(getVirtualFunctions) returns final functions

  • Loading branch information...
commit 89f321f5ee0d0c3eeed478a70ef1cd79116c6736 1 parent 366ec0e
Walter Bright authored January 22, 2012

Showing 1 changed file with 21 additions and 7 deletions. Show diff stats Hide diff stats

  1. 28  traits.dd
28  traits.dd
@@ -26,6 +26,7 @@ $(GNAME TraitsKeyword):
26 26
     $(GBLINK isStaticArray)
27 27
     $(GBLINK isUnsigned)
28 28
     $(GBLINK isVirtualFunction)
  29
+    $(GBLINK isVirtualMethod)
29 30
     $(GBLINK isAbstractFunction)
30 31
     $(GBLINK isFinalFunction)
31 32
     $(GBLINK isStaticFunction)
@@ -37,6 +38,7 @@ $(GNAME TraitsKeyword):
37 38
     $(GBLINK getMember)
38 39
     $(GBLINK getOverloads)
39 40
     $(GBLINK getVirtualFunctions)
  41
+    $(GBLINK getVirtualMethods)
40 42
     $(GBLINK parent)
41 43
     $(GBLINK classInstanceSize)
42 44
     $(GBLINK allMembers)
@@ -150,9 +152,15 @@ $(H2 $(GNAME isFinalClass))
150 152
 
151 153
 $(H2 $(GNAME isVirtualFunction))
152 154
 
  155
+	$(P The same as $(GLINK isVirtualMethod), except
  156
+	that final functions that don't override anything return true.
  157
+	)
  158
+
  159
+$(H2 $(GNAME isVirtualMethod))
  160
+
153 161
 	$(P Takes one argument. If that argument is a virtual function,
154 162
 	$(B true) is returned, otherwise $(B false).
155  
-	Note that final functions are virtual.
  163
+	Final functions that don't override anything return false.
156 164
 	)
157 165
 
158 166
 ---
@@ -167,8 +175,8 @@ class C {
167 175
 }
168 176
 
169 177
 void main() {
170  
-  writeln(__traits(isVirtualFunction, C.bar));  // true
171  
-  writeln(__traits(isVirtualFunction, S.bar));  // false
  178
+  writeln(__traits(isVirtualMethod, C.bar));  // true
  179
+  writeln(__traits(isVirtualMethod, S.bar));  // false
172 180
 }
173 181
 ---
174 182
 
@@ -371,12 +379,18 @@ int()
371 379
 
372 380
 $(H2 $(GNAME getVirtualFunctions))
373 381
 
  382
+	$(P The same as $(GLINK getVirtualMethods), except that
  383
+	final functions that do not override anything are included.
  384
+	)
  385
+
  386
+$(H2 $(GNAME getVirtualMethods))
  387
+
374 388
 	$(P The first argument is a class type or an expression of
375 389
 	class type.
376 390
 	The second argument is a string that matches the name of
377 391
 	one of the functions of that class.
378 392
 	The result is a tuple of the virtual overloads of that function.
379  
-	Note that final functions are virtual.
  393
+	It does not include final functions that do not override anything.
380 394
 	)
381 395
 
382 396
 ---
@@ -392,14 +406,14 @@ class D {
392 406
 void main() {
393 407
   D d = new D();
394 408
 
395  
-  foreach (t; __traits(getVirtualFunctions, D, "foo"))
  409
+  foreach (t; __traits(getVirtualMethods, D, "foo"))
396 410
     writeln(typeid(typeof(t)));
397 411
 
398  
-  alias typeof(__traits(getVirtualFunctions, D, "foo")) b;
  412
+  alias typeof(__traits(getVirtualMethods, D, "foo")) b;
399 413
   foreach (t; b)
400 414
     writeln(typeid(t));
401 415
 
402  
-  auto i = __traits(getVirtualFunctions, d, "foo")[1](1);
  416
+  auto i = __traits(getVirtualMethods, d, "foo")[1](1);
403 417
   writeln(i);
404 418
 }
405 419
 ---

0 notes on commit 89f321f

Please sign in to comment.
Something went wrong with that request. Please try again.