Skip to content

Commit 4bb31c3

Browse files
committed
fix Issue 3345: Static and nonstatic methods with teh same name should be allowed
1 parent 0a90480 commit 4bb31c3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

spec/function.dd

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,33 @@ void test()
13471347
specialized than a function without.
13481348
)
13491349

1350+
$(P A static member function can be overloaded with a member
1351+
function. The struct, class
1352+
or union of the static member function is inferred from the
1353+
type of the `this` argument.)
1354+
1355+
---
1356+
struct S {
1357+
void eggs(int);
1358+
static void eggs(long);
1359+
}
1360+
S s;
1361+
s.eggs(0); // calls void eggs(int);
1362+
S.eggs(0); // error: need `this`
1363+
s.eggs(0L); // calls static void eggs(long);
1364+
S.eggs(0L); // calls static void eggs(long);
1365+
1366+
struct T {
1367+
void bacon(int);
1368+
static void bacon(int);
1369+
}
1370+
T t;
1371+
t.bacon(0); // error: ambiguous
1372+
T.bacon(0); // error: ambiguous
1373+
---
1374+
1375+
$(RATIONALE A static member function that doesn't need
1376+
the `this` parameter does not need to pass it.)
13501377

13511378
$(H3 $(LNAME2 overload-sets, Overload Sets))
13521379

0 commit comments

Comments
 (0)