Skip to content

Commit

Permalink
fix Issue 1528 - [tdpl] overloading template and non-template functions
Browse files Browse the repository at this point in the history
- Improve `resolveFuncCall` for integrated function call resolution.
  All of error reporting is done in here.

- Remove `overloadResolve` and `deduceFuncitonTemplate`
  The works was in `overloadResolve` are moved to `resolveFuncCall`,
  and things was in `deduceFuncitonTemplate` are divided to
  `templateResolve` and `resolveFuncCall`.

- Change the name from `overloadResolveX` to `functionResolve`
  It is paired with `templateResolve`.

- Decide 'most specialized' function based on the two `MATCH` values derived from `tiargs` and `fargs`.
  With non template functions, `last matching level for tiargs` is treated as `MATCHexact`.

----
The bug that is fixed at the same time:
fix Issue 9596 - Ambiguous match is incorrectly hidden by additional lesser match

  The change in test/runnable/template9.d is related.
  • Loading branch information
9rnsr committed Jun 27, 2013
1 parent 74f85b5 commit edd0f6f
Show file tree
Hide file tree
Showing 11 changed files with 562 additions and 344 deletions.
5 changes: 3 additions & 2 deletions src/declaration.h
Expand Up @@ -102,8 +102,10 @@ struct Match
FuncDeclaration *anyf; // pick a func, any func, to use for error recovery
};

void overloadResolveX(Match *m, FuncDeclaration *f,
void functionResolve(Match *m, FuncDeclaration *f,
Type *tthis, Expressions *arguments, Dsymbol **plast = NULL);
void templateResolve(Match *m, TemplateDeclaration *td, Loc loc, Scope *sc,
Objects *tiargs, Type *tthis, Expressions *fargs);
int overloadApply(FuncDeclaration *fstart,
int (*fp)(void *, FuncDeclaration *),
void *param, Dsymbol **plast = NULL);
Expand Down Expand Up @@ -669,7 +671,6 @@ class FuncDeclaration : public Declaration
int findVtblIndex(Dsymbols *vtbl, int dim);
bool overloadInsert(Dsymbol *s);
FuncDeclaration *overloadExactMatch(Type *t);
FuncDeclaration *overloadResolve(Loc loc, Type *tthis, Expressions *arguments, int flags = 0);
TemplateDeclaration *findTemplateDeclRoot();
MATCH leastAsSpecialized(FuncDeclaration *g);
LabelDsymbol *searchLabel(Identifier *ident);
Expand Down
10 changes: 5 additions & 5 deletions src/expression.c
Expand Up @@ -1747,12 +1747,12 @@ void argsToCBuffer(OutBuffer *buf, Expressions *expressions, HdrGenState *hgs)

void argExpTypesToCBuffer(OutBuffer *buf, Expressions *arguments, HdrGenState *hgs)
{
if (arguments)
{ OutBuffer argbuf;

if (arguments && arguments->dim)
{
OutBuffer argbuf;
for (size_t i = 0; i < arguments->dim; i++)
{ Expression *e = (*arguments)[i];

{
Expression *e = (*arguments)[i];
if (i)
buf->writestring(", ");
argbuf.reset();
Expand Down

0 comments on commit edd0f6f

Please sign in to comment.