@@ -6757,10 +6757,11 @@ void MissingGenericArgumentsFailure::emitGenericSignatureNote(
67576757 auto diagnostic = emitDiagnosticAt (
67586758 baseType->getLoc (), diag::unbound_generic_parameter_explicit_fix);
67596759
6760- if (auto *genericTy = dyn_cast<GenericIdentTypeRepr>(baseType)) {
6761- // If some of the eneric arguments have been specified, we need to
6760+ auto *declRefTR = dyn_cast<DeclRefTypeRepr>(baseType);
6761+ if (declRefTR && declRefTR->getAngleBrackets ().isValid ()) {
6762+ // If some of the generic arguments have been specified, we need to
67626763 // replace existing signature with a new one.
6763- diagnostic.fixItReplace (genericTy ->getAngleBrackets (), paramsAsString);
6764+ diagnostic.fixItReplace (declRefTR ->getAngleBrackets (), paramsAsString);
67646765 } else {
67656766 // Otherwise we can simply insert new generic signature.
67666767 diagnostic.fixItInsertAfter (baseType->getEndLoc (), paramsAsString);
@@ -6770,7 +6771,7 @@ void MissingGenericArgumentsFailure::emitGenericSignatureNote(
67706771
67716772bool MissingGenericArgumentsFailure::findArgumentLocations (
67726773 llvm::function_ref<void (TypeRepr *, GenericTypeParamType *)> callback) {
6773- using Callback = llvm::function_ref< void (TypeRepr *, GenericTypeParamType *)> ;
6774+ using Callback = decltype (callback) ;
67746775
67756776 auto *const typeRepr = [this ]() -> TypeRepr * {
67766777 const auto anchor = getRawAnchor ();
@@ -6799,14 +6800,14 @@ bool MissingGenericArgumentsFailure::findArgumentLocations(
67996800 }
68006801
68016802 PreWalkAction walkToTypeReprPre (TypeRepr *T) override {
6802- if (Params. empty ())
6803- return Action::SkipNode ();
6803+ if (allParamsAssigned ())
6804+ return Action::Stop ();
68046805
6805- auto *ident = dyn_cast<IdentTypeRepr >(T);
6806- if (!ident )
6806+ auto *declRefTR = dyn_cast<DeclRefTypeRepr >(T);
6807+ if (!declRefTR )
68076808 return Action::Continue ();
68086809
6809- auto *decl = dyn_cast_or_null<GenericTypeDecl>(ident ->getBoundDecl ());
6810+ auto *decl = dyn_cast_or_null<GenericTypeDecl>(declRefTR ->getBoundDecl ());
68106811 if (!decl)
68116812 return Action::Continue ();
68126813
@@ -6817,9 +6818,8 @@ bool MissingGenericArgumentsFailure::findArgumentLocations(
68176818 // There could a situation like `S<S>()`, so we need to be
68186819 // careful not to point at first `S` because it has all of
68196820 // its generic parameters specified.
6820- if (auto *generic = dyn_cast<GenericIdentTypeRepr>(ident)) {
6821- if (paramList->size () == generic->getNumGenericArgs ())
6822- return Action::Continue ();
6821+ if (paramList->size () == declRefTR->getNumGenericArgs ()) {
6822+ return Action::Continue ();
68236823 }
68246824
68256825 for (auto *candidate : paramList->getParams ()) {
@@ -6829,7 +6829,7 @@ bool MissingGenericArgumentsFailure::findArgumentLocations(
68296829 });
68306830
68316831 if (result != Params.end ()) {
6832- Fn (ident , *result);
6832+ Fn (declRefTR , *result);
68336833 Params.erase (result);
68346834 }
68356835 }
0 commit comments