@@ -303,7 +303,7 @@ static ParameterList *getParameterList(ValueDecl *decl) {
303303 return nullptr ;
304304}
305305
306- ResolvedLocator constraints::resolveLocatorToDecl (
306+ ConcreteDeclRef constraints::resolveLocatorToDecl (
307307 ConstraintSystem &cs,
308308 ConstraintLocator *locator,
309309 std::function<Optional<SelectedOverload>(ConstraintLocator *)> findOvlChoice,
@@ -312,7 +312,7 @@ ResolvedLocator constraints::resolveLocatorToDecl(
312312{
313313 assert (locator && " Null locator" );
314314 if (!locator->getAnchor ())
315- return ResolvedLocator ();
315+ return ConcreteDeclRef ();
316316
317317 ConcreteDeclRef declRef;
318318 auto anchor = locator->getAnchor ();
@@ -391,7 +391,7 @@ ResolvedLocator constraints::resolveLocatorToDecl(
391391
392392 // If we didn't find the declaration, we're out of luck.
393393 if (!declRef)
394- return ResolvedLocator ();
394+ return ConcreteDeclRef ();
395395
396396 // Use the declaration and the path to produce a more specific result.
397397 // FIXME: This is an egregious hack. We'd be far better off
@@ -416,10 +416,8 @@ ResolvedLocator constraints::resolveLocatorToDecl(
416416 if (!parameterList) break ;
417417
418418 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);
423421 break ;
424422 }
425423
@@ -431,14 +429,13 @@ ResolvedLocator constraints::resolveLocatorToDecl(
431429 }
432430
433431 // 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-
439432 // FIXME: Deal with the other interesting cases here, e.g.,
440433 // subscript declarations.
441- return ResolvedLocator ();
434+ if (isa<FuncDecl>(declRef.getDecl ()) ||
435+ isa<ConstructorDecl>(declRef.getDecl ()))
436+ return declRef;
437+
438+ return ConcreteDeclRef ();
442439}
443440
444441// / Emit a note referring to the target of a diagnostic, e.g., the function
@@ -463,32 +460,29 @@ static void noteTargetOfDiagnostic(ConstraintSystem &cs,
463460 if (!resolved)
464461 return ;
465462
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,
474467 name.isOperator ()? diag::note_call_to_operator
475468 : diag::note_call_to_func,
476- resolved. getDecl (). getDecl ()-> getName () );
469+ name );
477470 return ;
478471 }
479472
480- case ResolvedLocatorKind::Constructor:
473+ if (isa<ConstructorDecl>(decl)) {
481474 // 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);
484476 return ;
477+ }
485478
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 ());
490482 return ;
491483 }
484+
485+ // FIXME: Other decl types too.
492486}
493487
494488// / \brief Determine the number of distinct overload choices in the
0 commit comments