@@ -6757,10 +6757,11 @@ void MissingGenericArgumentsFailure::emitGenericSignatureNote(
6757
6757
auto diagnostic = emitDiagnosticAt (
6758
6758
baseType->getLoc (), diag::unbound_generic_parameter_explicit_fix);
6759
6759
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
6762
6763
// replace existing signature with a new one.
6763
- diagnostic.fixItReplace (genericTy ->getAngleBrackets (), paramsAsString);
6764
+ diagnostic.fixItReplace (declRefTR ->getAngleBrackets (), paramsAsString);
6764
6765
} else {
6765
6766
// Otherwise we can simply insert new generic signature.
6766
6767
diagnostic.fixItInsertAfter (baseType->getEndLoc (), paramsAsString);
@@ -6770,7 +6771,7 @@ void MissingGenericArgumentsFailure::emitGenericSignatureNote(
6770
6771
6771
6772
bool MissingGenericArgumentsFailure::findArgumentLocations (
6772
6773
llvm::function_ref<void (TypeRepr *, GenericTypeParamType *)> callback) {
6773
- using Callback = llvm::function_ref< void (TypeRepr *, GenericTypeParamType *)> ;
6774
+ using Callback = decltype (callback) ;
6774
6775
6775
6776
auto *const typeRepr = [this ]() -> TypeRepr * {
6776
6777
const auto anchor = getRawAnchor ();
@@ -6799,14 +6800,14 @@ bool MissingGenericArgumentsFailure::findArgumentLocations(
6799
6800
}
6800
6801
6801
6802
PreWalkAction walkToTypeReprPre (TypeRepr *T) override {
6802
- if (Params. empty ())
6803
- return Action::SkipNode ();
6803
+ if (allParamsAssigned ())
6804
+ return Action::Stop ();
6804
6805
6805
- auto *ident = dyn_cast<IdentTypeRepr >(T);
6806
- if (!ident )
6806
+ auto *declRefTR = dyn_cast<DeclRefTypeRepr >(T);
6807
+ if (!declRefTR )
6807
6808
return Action::Continue ();
6808
6809
6809
- auto *decl = dyn_cast_or_null<GenericTypeDecl>(ident ->getBoundDecl ());
6810
+ auto *decl = dyn_cast_or_null<GenericTypeDecl>(declRefTR ->getBoundDecl ());
6810
6811
if (!decl)
6811
6812
return Action::Continue ();
6812
6813
@@ -6817,9 +6818,8 @@ bool MissingGenericArgumentsFailure::findArgumentLocations(
6817
6818
// There could a situation like `S<S>()`, so we need to be
6818
6819
// careful not to point at first `S` because it has all of
6819
6820
// 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 ();
6823
6823
}
6824
6824
6825
6825
for (auto *candidate : paramList->getParams ()) {
@@ -6829,7 +6829,7 @@ bool MissingGenericArgumentsFailure::findArgumentLocations(
6829
6829
});
6830
6830
6831
6831
if (result != Params.end ()) {
6832
- Fn (ident , *result);
6832
+ Fn (declRefTR , *result);
6833
6833
Params.erase (result);
6834
6834
}
6835
6835
}
0 commit comments