@@ -681,11 +681,11 @@ const types::Param* Resolver::determineWhenCaseValue(const uast::AstNode* ast, I
681
681
/* hasQuestionArg */ false ,
682
682
/* isParenless */ false ,
683
683
actuals);
684
- auto c = resolveGeneratedCall (ast, &ci, &inScopes);
685
- c.noteResult (&caseResult, { { AssociatedAction::COMPARE, ast->id () } });
686
684
685
+ auto c = resolveGeneratedCall (ast, &ci, &inScopes);
687
686
auto type = c.result .exprType ();
688
- caseResult.setType (type);
687
+ c.noteResult (&caseResult, { { AssociatedAction::COMPARE, ast->id (), type } });
688
+
689
689
return type.param ();
690
690
}
691
691
@@ -2308,7 +2308,7 @@ bool Resolver::CallResultWrapper::noteResultWithoutError(
2308
2308
ResolvedExpression* r,
2309
2309
const uast::AstNode* astForContext,
2310
2310
const CallResolutionResult& result,
2311
- optional<ActionAndId> actionAndId ) {
2311
+ optional<ActionInfo> actionInfo ) {
2312
2312
bool needsErrors = false ;
2313
2313
bool markErroneous = false ;
2314
2314
@@ -2339,7 +2339,7 @@ bool Resolver::CallResultWrapper::noteResultWithoutError(
2339
2339
}
2340
2340
2341
2341
if (!result.exprType ().hasTypePtr () || markErroneous) {
2342
- if (!actionAndId && r) {
2342
+ if (!actionInfo && r) {
2343
2343
// Only set the type to erroneous if we're handling an actual user call,
2344
2344
// and not an associated action.
2345
2345
r->setType (QualifiedType (r->type ().kind (), ErroneousType::get (resolver.context )));
@@ -2350,12 +2350,22 @@ bool Resolver::CallResultWrapper::noteResultWithoutError(
2350
2350
// issued its own error, so we shouldn't emit a general error.
2351
2351
return !result.speciallyHandled () || needsErrors;
2352
2352
} else {
2353
- if (actionAndId ) {
2353
+ if (actionInfo ) {
2354
2354
// save candidates as associated functions
2355
- for (auto & sig : result.mostSpecific ()) {
2356
- if (sig && r) {
2357
- r->addAssociatedAction (std::get<0 >(*actionAndId), sig.fn (),
2358
- std::get<1 >(*actionAndId));
2355
+ if (result.mostSpecific ().isEmpty () && r) {
2356
+ // Store an associated action that did not have a function.
2357
+ // E.g., 'COMPARE' for a when-statement condition that is param-true
2358
+ r->addAssociatedAction (actionInfo->action , nullptr ,
2359
+ actionInfo->id , actionInfo->type );
2360
+ } else {
2361
+ bool seen = false ;
2362
+ for (auto & sig : result.mostSpecific ()) {
2363
+ if (sig && r) {
2364
+ CHPL_ASSERT (!seen);
2365
+ seen = true ;
2366
+ r->addAssociatedAction (actionInfo->action , sig.fn (),
2367
+ actionInfo->id , actionInfo->type );
2368
+ }
2359
2369
}
2360
2370
}
2361
2371
} else if (r) {
@@ -2372,13 +2382,13 @@ bool Resolver::CallResultWrapper::noteResultWithoutError(
2372
2382
2373
2383
2374
2384
bool Resolver::CallResultWrapper::noteResultWithoutError (ResolvedExpression* r,
2375
- optional<ActionAndId> actionAndId ) {
2376
- return noteResultWithoutError (*parent, r, astForContext, result, std::move (actionAndId ));
2385
+ optional<ActionInfo> actionInfo ) {
2386
+ return noteResultWithoutError (*parent, r, astForContext, result, std::move (actionInfo ));
2377
2387
}
2378
2388
2379
2389
void Resolver::CallResultWrapper::noteResult (ResolvedExpression* r,
2380
- optional<ActionAndId> actionAndId ) {
2381
- if (noteResultWithoutError (r, std::move (actionAndId ))) {
2390
+ optional<ActionInfo> actionInfo ) {
2391
+ if (noteResultWithoutError (r, std::move (actionInfo ))) {
2382
2392
issueBasicError ();
2383
2393
}
2384
2394
}
@@ -2414,9 +2424,9 @@ bool Resolver::CallResultWrapper::rerunCallAndPrintCandidates() {
2414
2424
}
2415
2425
2416
2426
void Resolver::CallResultWrapper::noteResultPrintCandidates (ResolvedExpression* r,
2417
- optional<ActionAndId> actionAndId ) {
2427
+ optional<ActionInfo> actionInfo ) {
2418
2428
CHPL_ASSERT (!wasGeneratedCall || receiverType.isUnknown ());
2419
- if (noteResultWithoutError (r, std::move (actionAndId ))) {
2429
+ if (noteResultWithoutError (r, std::move (actionInfo ))) {
2420
2430
if (rerunCallAndPrintCandidates ()) {
2421
2431
return ;
2422
2432
}
@@ -2792,7 +2802,7 @@ bool Resolver::resolveSpecialNewCall(const Call* call) {
2792
2802
2793
2803
// note: the resolution machinery will get compiler generated candidates
2794
2804
auto c = resolveGeneratedCall (call, &ci, &inScopes);
2795
- optional<ActionAndId > action ({ AssociatedAction::NEW_INIT, call->id () });
2805
+ optional<ActionInfo > action ({ AssociatedAction::NEW_INIT, call->id () });
2796
2806
c.noteResultPrintCandidates (&re, std::move (action));
2797
2807
2798
2808
@@ -3221,7 +3231,7 @@ bool Resolver::resolveSpecialKeywordCall(const Call* call) {
3221
3231
3222
3232
// Note: this issues errors from compilerError in the body of the
3223
3233
// domain builder.
3224
- optional<ActionAndId > action ({ AssociatedAction::RUNTIME_TYPE, fnCall->id () });
3234
+ optional<ActionInfo > action ({ AssociatedAction::RUNTIME_TYPE, fnCall->id () });
3225
3235
bool needsErrors =
3226
3236
runResult.result ().noteResultWithoutError (&r, std::move (action));
3227
3237
@@ -4717,8 +4727,8 @@ bool Resolver::enter(const uast::Manage* manage) {
4717
4727
}
4718
4728
}
4719
4729
CHPL_ASSERT (enterSig && exitSig);
4720
- rr.addAssociatedAction (AssociatedAction::ENTER_CONTEXT, enterSig, manage->id ());
4721
- rr.addAssociatedAction (AssociatedAction::EXIT_CONTEXT, exitSig, manage->id ());
4730
+ rr.addAssociatedAction (AssociatedAction::ENTER_CONTEXT, enterSig, manage->id (), {} );
4731
+ rr.addAssociatedAction (AssociatedAction::EXIT_CONTEXT, exitSig, manage->id (), {} );
4722
4732
}
4723
4733
4724
4734
enterScope (manage);
@@ -5228,7 +5238,7 @@ rerunCallInfoWithIteratorTag(ResolutionContext* rc,
5228
5238
if (!newC.mostSpecific ().isEmpty ()) {
5229
5239
for (auto sig : newC.mostSpecific ()) {
5230
5240
if (!sig) continue ;
5231
- r.addAssociatedAction (AssociatedAction::ITERATE, sig.fn (), call->id ());
5241
+ r.addAssociatedAction (AssociatedAction::ITERATE, sig.fn (), call->id (), {} );
5232
5242
}
5233
5243
5234
5244
return newC;
0 commit comments