@@ -313,7 +313,7 @@ static ParameterList *getParameterList(ValueDecl *decl) {
313
313
return nullptr ;
314
314
}
315
315
316
- ResolvedLocator constraints::resolveLocatorToDecl (
316
+ ConcreteDeclRef constraints::resolveLocatorToDecl (
317
317
ConstraintSystem &cs,
318
318
ConstraintLocator *locator,
319
319
std::function<Optional<SelectedOverload>(ConstraintLocator *)> findOvlChoice,
@@ -322,7 +322,7 @@ ResolvedLocator constraints::resolveLocatorToDecl(
322
322
{
323
323
assert (locator && " Null locator" );
324
324
if (!locator->getAnchor ())
325
- return ResolvedLocator ();
325
+ return ConcreteDeclRef ();
326
326
327
327
ConcreteDeclRef declRef;
328
328
auto anchor = locator->getAnchor ();
@@ -401,7 +401,7 @@ ResolvedLocator constraints::resolveLocatorToDecl(
401
401
402
402
// If we didn't find the declaration, we're out of luck.
403
403
if (!declRef)
404
- return ResolvedLocator ();
404
+ return ConcreteDeclRef ();
405
405
406
406
// Use the declaration and the path to produce a more specific result.
407
407
// FIXME: This is an egregious hack. We'd be far better off
@@ -426,10 +426,8 @@ ResolvedLocator constraints::resolveLocatorToDecl(
426
426
if (!parameterList) break ;
427
427
428
428
unsigned index = path[0 ].getValue2 ();
429
- if (index < parameterList->size ()) {
430
- auto param = parameterList->get (index);
431
- return ResolvedLocator (ResolvedLocator::ForVar, param);
432
- }
429
+ if (index < parameterList->size ())
430
+ return parameterList->get (index);
433
431
break ;
434
432
}
435
433
@@ -441,14 +439,13 @@ ResolvedLocator constraints::resolveLocatorToDecl(
441
439
}
442
440
443
441
// Otherwise, do the best we can with the declaration we found.
444
- if (isa<FuncDecl>(declRef.getDecl ()))
445
- return ResolvedLocator (ResolvedLocator::ForFunction, declRef);
446
- if (isa<ConstructorDecl>(declRef.getDecl ()))
447
- return ResolvedLocator (ResolvedLocator::ForConstructor, declRef);
448
-
449
442
// FIXME: Deal with the other interesting cases here, e.g.,
450
443
// subscript declarations.
451
- return ResolvedLocator ();
444
+ if (isa<FuncDecl>(declRef.getDecl ()) ||
445
+ isa<ConstructorDecl>(declRef.getDecl ()))
446
+ return declRef;
447
+
448
+ return ConcreteDeclRef ();
452
449
}
453
450
454
451
// / Emit a note referring to the target of a diagnostic, e.g., the function
@@ -473,32 +470,29 @@ static void noteTargetOfDiagnostic(ConstraintSystem &cs,
473
470
if (!resolved)
474
471
return ;
475
472
476
- switch (resolved.getKind ()) {
477
- case ResolvedLocatorKind::Unresolved:
478
- // Can't emit any diagnostic here.
479
- return ;
480
-
481
- case ResolvedLocatorKind::Function: {
482
- auto name = resolved.getDecl ().getDecl ()->getName ();
483
- cs.getTypeChecker ().diagnose (resolved.getDecl ().getDecl (),
473
+ auto decl = resolved.getDecl ();
474
+ if (isa<FuncDecl>(decl)) {
475
+ auto name = decl->getName ();
476
+ cs.getTypeChecker ().diagnose (decl,
484
477
name.isOperator ()? diag::note_call_to_operator
485
478
: diag::note_call_to_func,
486
- resolved. getDecl (). getDecl ()-> getName () );
479
+ name );
487
480
return ;
488
481
}
489
482
490
- case ResolvedLocatorKind::Constructor:
483
+ if (isa<ConstructorDecl>(decl)) {
491
484
// FIXME: Specialize for implicitly-generated constructors.
492
- cs.getTypeChecker ().diagnose (resolved.getDecl ().getDecl (),
493
- diag::note_call_to_initializer);
485
+ cs.getTypeChecker ().diagnose (decl, diag::note_call_to_initializer);
494
486
return ;
487
+ }
495
488
496
- case ResolvedLocatorKind::Parameter:
497
- cs.getTypeChecker ().diagnose (resolved.getDecl ().getDecl (),
498
- diag::note_init_parameter,
499
- resolved.getDecl ().getDecl ()->getName ());
489
+ if (isa<ParamDecl>(decl)) {
490
+ cs.getTypeChecker ().diagnose (decl, diag::note_init_parameter,
491
+ decl->getName ());
500
492
return ;
501
493
}
494
+
495
+ // FIXME: Other decl types too.
502
496
}
503
497
504
498
// / \brief Determine the number of distinct overload choices in the
0 commit comments