@@ -303,7 +303,7 @@ static ParameterList *getParameterList(ValueDecl *decl) {
303
303
return nullptr ;
304
304
}
305
305
306
- ResolvedLocator constraints::resolveLocatorToDecl (
306
+ ConcreteDeclRef constraints::resolveLocatorToDecl (
307
307
ConstraintSystem &cs,
308
308
ConstraintLocator *locator,
309
309
std::function<Optional<SelectedOverload>(ConstraintLocator *)> findOvlChoice,
@@ -312,7 +312,7 @@ ResolvedLocator constraints::resolveLocatorToDecl(
312
312
{
313
313
assert (locator && " Null locator" );
314
314
if (!locator->getAnchor ())
315
- return ResolvedLocator ();
315
+ return ConcreteDeclRef ();
316
316
317
317
ConcreteDeclRef declRef;
318
318
auto anchor = locator->getAnchor ();
@@ -391,7 +391,7 @@ ResolvedLocator constraints::resolveLocatorToDecl(
391
391
392
392
// If we didn't find the declaration, we're out of luck.
393
393
if (!declRef)
394
- return ResolvedLocator ();
394
+ return ConcreteDeclRef ();
395
395
396
396
// Use the declaration and the path to produce a more specific result.
397
397
// FIXME: This is an egregious hack. We'd be far better off
@@ -416,10 +416,8 @@ ResolvedLocator constraints::resolveLocatorToDecl(
416
416
if (!parameterList) break ;
417
417
418
418
unsigned index = path[0 ].getValue2 ();
419
- if (index < parameterList->size ()) {
420
- auto param = parameterList->get (index);
421
- return ResolvedLocator (ResolvedLocator::ForVar, param);
422
- }
419
+ if (index < parameterList->size ())
420
+ return parameterList->get (index);
423
421
break ;
424
422
}
425
423
@@ -431,14 +429,13 @@ ResolvedLocator constraints::resolveLocatorToDecl(
431
429
}
432
430
433
431
// Otherwise, do the best we can with the declaration we found.
434
- if (isa<FuncDecl>(declRef.getDecl ()))
435
- return ResolvedLocator (ResolvedLocator::ForFunction, declRef);
436
- if (isa<ConstructorDecl>(declRef.getDecl ()))
437
- return ResolvedLocator (ResolvedLocator::ForConstructor, declRef);
438
-
439
432
// FIXME: Deal with the other interesting cases here, e.g.,
440
433
// subscript declarations.
441
- return ResolvedLocator ();
434
+ if (isa<FuncDecl>(declRef.getDecl ()) ||
435
+ isa<ConstructorDecl>(declRef.getDecl ()))
436
+ return declRef;
437
+
438
+ return ConcreteDeclRef ();
442
439
}
443
440
444
441
// / Emit a note referring to the target of a diagnostic, e.g., the function
@@ -463,32 +460,29 @@ static void noteTargetOfDiagnostic(ConstraintSystem &cs,
463
460
if (!resolved)
464
461
return ;
465
462
466
- switch (resolved.getKind ()) {
467
- case ResolvedLocatorKind::Unresolved:
468
- // Can't emit any diagnostic here.
469
- return ;
470
-
471
- case ResolvedLocatorKind::Function: {
472
- auto name = resolved.getDecl ().getDecl ()->getName ();
473
- cs.getTypeChecker ().diagnose (resolved.getDecl ().getDecl (),
463
+ auto decl = resolved.getDecl ();
464
+ if (isa<FuncDecl>(decl)) {
465
+ auto name = decl->getName ();
466
+ cs.getTypeChecker ().diagnose (decl,
474
467
name.isOperator ()? diag::note_call_to_operator
475
468
: diag::note_call_to_func,
476
- resolved. getDecl (). getDecl ()-> getName () );
469
+ name );
477
470
return ;
478
471
}
479
472
480
- case ResolvedLocatorKind::Constructor:
473
+ if (isa<ConstructorDecl>(decl)) {
481
474
// FIXME: Specialize for implicitly-generated constructors.
482
- cs.getTypeChecker ().diagnose (resolved.getDecl ().getDecl (),
483
- diag::note_call_to_initializer);
475
+ cs.getTypeChecker ().diagnose (decl, diag::note_call_to_initializer);
484
476
return ;
477
+ }
485
478
486
- case ResolvedLocatorKind::Parameter:
487
- cs.getTypeChecker ().diagnose (resolved.getDecl ().getDecl (),
488
- diag::note_init_parameter,
489
- resolved.getDecl ().getDecl ()->getName ());
479
+ if (isa<ParamDecl>(decl)) {
480
+ cs.getTypeChecker ().diagnose (decl, diag::note_init_parameter,
481
+ decl->getName ());
490
482
return ;
491
483
}
484
+
485
+ // FIXME: Other decl types too.
492
486
}
493
487
494
488
// / \brief Determine the number of distinct overload choices in the
0 commit comments