Mercurial > projects > ldc
comparison dmd/opover.c @ 1358:78038e540342
Fix overload resolution issue in dmd bug 313/314 fix.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sat, 16 May 2009 12:17:33 +0200 |
parents | e961851fb8be |
children | def7a1d494fd |
comparison
equal
deleted
inserted
replaced
1357:48747003a5de | 1358:78038e540342 |
---|---|
26 #include "expression.h" | 26 #include "expression.h" |
27 #include "id.h" | 27 #include "id.h" |
28 #include "declaration.h" | 28 #include "declaration.h" |
29 #include "aggregate.h" | 29 #include "aggregate.h" |
30 #include "template.h" | 30 #include "template.h" |
31 #include "scope.h" | |
31 | 32 |
32 static Expression *build_overload(Loc loc, Scope *sc, Expression *ethis, Expression *earg, Identifier *id); | 33 static Expression *build_overload(Loc loc, Scope *sc, Expression *ethis, Expression *earg, Identifier *id); |
33 static void inferApplyArgTypesX(FuncDeclaration *fstart, Arguments *arguments); | 34 static void inferApplyArgTypesX(Module* from, FuncDeclaration *fstart, Arguments *arguments); |
34 static int inferApplyArgTypesY(TypeFunction *tf, Arguments *arguments); | 35 static int inferApplyArgTypesY(TypeFunction *tf, Arguments *arguments); |
35 static void templateResolve(Match *m, TemplateDeclaration *td, Scope *sc, Loc loc, Objects *targsi, Expressions *arguments); | 36 static void templateResolve(Match *m, TemplateDeclaration *td, Scope *sc, Loc loc, Objects *targsi, Expressions *arguments); |
36 | 37 |
37 /******************************** Expression **************************/ | 38 /******************************** Expression **************************/ |
38 | 39 |
261 if (s) | 262 if (s) |
262 { | 263 { |
263 fd = s->isFuncDeclaration(); | 264 fd = s->isFuncDeclaration(); |
264 if (fd) | 265 if (fd) |
265 { | 266 { |
266 overloadResolveX(&m, fd, &args2); | 267 overloadResolveX(&m, fd, &args2, sc->module); |
267 } | 268 } |
268 else | 269 else |
269 { td = s->isTemplateDeclaration(); | 270 { td = s->isTemplateDeclaration(); |
270 templateResolve(&m, td, sc, loc, NULL, &args2); | 271 templateResolve(&m, td, sc, loc, NULL, &args2); |
271 } | 272 } |
276 if (s_r) | 277 if (s_r) |
277 { | 278 { |
278 fd = s_r->isFuncDeclaration(); | 279 fd = s_r->isFuncDeclaration(); |
279 if (fd) | 280 if (fd) |
280 { | 281 { |
281 overloadResolveX(&m, fd, &args1); | 282 overloadResolveX(&m, fd, &args1, sc->module); |
282 } | 283 } |
283 else | 284 else |
284 { td = s_r->isTemplateDeclaration(); | 285 { td = s_r->isTemplateDeclaration(); |
285 templateResolve(&m, td, sc, loc, NULL, &args1); | 286 templateResolve(&m, td, sc, loc, NULL, &args1); |
286 } | 287 } |
350 if (s_r) | 351 if (s_r) |
351 { | 352 { |
352 fd = s_r->isFuncDeclaration(); | 353 fd = s_r->isFuncDeclaration(); |
353 if (fd) | 354 if (fd) |
354 { | 355 { |
355 overloadResolveX(&m, fd, &args2); | 356 overloadResolveX(&m, fd, &args2, sc->module); |
356 } | 357 } |
357 else | 358 else |
358 { td = s_r->isTemplateDeclaration(); | 359 { td = s_r->isTemplateDeclaration(); |
359 templateResolve(&m, td, sc, loc, NULL, &args2); | 360 templateResolve(&m, td, sc, loc, NULL, &args2); |
360 } | 361 } |
364 if (s) | 365 if (s) |
365 { | 366 { |
366 fd = s->isFuncDeclaration(); | 367 fd = s->isFuncDeclaration(); |
367 if (fd) | 368 if (fd) |
368 { | 369 { |
369 overloadResolveX(&m, fd, &args1); | 370 overloadResolveX(&m, fd, &args1, sc->module); |
370 } | 371 } |
371 else | 372 else |
372 { td = s->isTemplateDeclaration(); | 373 { td = s->isTemplateDeclaration(); |
373 templateResolve(&m, td, sc, loc, NULL, &args1); | 374 templateResolve(&m, td, sc, loc, NULL, &args1); |
374 } | 375 } |
480 * Given array of arguments and an aggregate type, | 481 * Given array of arguments and an aggregate type, |
481 * if any of the argument types are missing, attempt to infer | 482 * if any of the argument types are missing, attempt to infer |
482 * them from the aggregate type. | 483 * them from the aggregate type. |
483 */ | 484 */ |
484 | 485 |
485 void inferApplyArgTypes(enum TOK op, Arguments *arguments, Expression *aggr) | 486 void inferApplyArgTypes(enum TOK op, Arguments *arguments, Expression *aggr, Module* from) |
486 { | 487 { |
487 if (!arguments || !arguments->dim) | 488 if (!arguments || !arguments->dim) |
488 return; | 489 return; |
489 | 490 |
490 /* Return if no arguments need types. | 491 /* Return if no arguments need types. |
569 : Id::apply); | 570 : Id::apply); |
570 if (s) | 571 if (s) |
571 { | 572 { |
572 fd = s->isFuncDeclaration(); | 573 fd = s->isFuncDeclaration(); |
573 if (fd) | 574 if (fd) |
574 inferApplyArgTypesX(fd, arguments); | 575 inferApplyArgTypesX(from, fd, arguments); |
575 } | 576 } |
576 break; | 577 break; |
577 } | 578 } |
578 | 579 |
579 case Tdelegate: | 580 case Tdelegate: |
581 if (0 && aggr->op == TOKdelegate) | 582 if (0 && aggr->op == TOKdelegate) |
582 { DelegateExp *de = (DelegateExp *)aggr; | 583 { DelegateExp *de = (DelegateExp *)aggr; |
583 | 584 |
584 fd = de->func->isFuncDeclaration(); | 585 fd = de->func->isFuncDeclaration(); |
585 if (fd) | 586 if (fd) |
586 inferApplyArgTypesX(fd, arguments); | 587 inferApplyArgTypesX(from, fd, arguments); |
587 } | 588 } |
588 else | 589 else |
589 { | 590 { |
590 inferApplyArgTypesY((TypeFunction *)tab->nextOf(), arguments); | 591 inferApplyArgTypesY((TypeFunction *)tab->nextOf(), arguments); |
591 } | 592 } |
611 if (arguments->dim == 0) | 612 if (arguments->dim == 0) |
612 return 1; | 613 return 1; |
613 return 0; | 614 return 0; |
614 } | 615 } |
615 | 616 |
616 static void inferApplyArgTypesX(FuncDeclaration *fstart, Arguments *arguments) | 617 static void inferApplyArgTypesX(Module* from, FuncDeclaration *fstart, Arguments *arguments) |
617 { | 618 { |
618 overloadApply(fstart, &fp3, arguments); | 619 overloadApply(from, fstart, &fp3, arguments); |
619 } | 620 } |
620 | 621 |
621 #if 0 | 622 #if 0 |
622 static void inferApplyArgTypesX(FuncDeclaration *fstart, Arguments *arguments) | 623 static void inferApplyArgTypesX(FuncDeclaration *fstart, Arguments *arguments) |
623 { | 624 { |