1
2
3
4
5
6
7
8
9
|
#include "builtins/builtins.h"
//#define OVL_TC_DEBUG
using namespace goose::sema;
namespace goose::builtins
{
class OverloadSetInvocationRule : public InvocationRule
|
>
|
1
2
3
4
5
6
7
8
9
10
|
#include "builtins/builtins.h"
//#define OVL_TC_DEBUG_CANDIDATES
//#define OVL_TC_DEBUG
using namespace goose::sema;
namespace goose::builtins
{
class OverloadSetInvocationRule : public InvocationRule
|
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
TypeCheckingContext tcc( c );
for( auto&& [s,ovl,tcc] : pOvlSet->typeCheck( callPat, tcc ) )
{
if( tcc.numUnknownValues() )
continue;
auto subs = Substitute( s, tcc );
// Typechecking rules often end up stripping part of the original type,
// and we want to invoke the overload where these removals are minimized.
//
// Obvious example: if there is an overload that accepts a reference
// and one that accepts a value of the same type and we started with a
// reference, then we want to call the overload where the typechecking
|
>
>
>
>
|
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
TypeCheckingContext tcc( c );
for( auto&& [s,ovl,tcc] : pOvlSet->typeCheck( callPat, tcc ) )
{
if( tcc.numUnknownValues() )
continue;
auto subs = Substitute( s, tcc );
#ifdef OVL_TC_DEBUG_CANDIDATES
cout << " ## CANDIDATE: " << tcc.score() << " " << subs << endl;
#endif
// Typechecking rules often end up stripping part of the original type,
// and we want to invoke the overload where these removals are minimized.
//
// Obvious example: if there is an overload that accepts a reference
// and one that accepts a value of the same type and we started with a
// reference, then we want to call the overload where the typechecking
|