@@ -277,6 +277,22 @@ FailureDiagnostic::getFunctionArgApplyInfo(ConstraintLocator *locator) const {
277
277
fnInterfaceType, fnType, callee);
278
278
}
279
279
280
+ Type FailureDiagnostic::restoreGenericParameters (
281
+ Type type,
282
+ llvm::function_ref<void (GenericTypeParamType *, Type)> substitution) {
283
+ return type.transform ([&](Type type) -> Type {
284
+ if (auto *typeVar = type->getAs <TypeVariableType>()) {
285
+ type = resolveType (typeVar);
286
+ if (auto *GP = typeVar->getImpl ().getGenericParameter ()) {
287
+ substitution (GP, type);
288
+ return GP;
289
+ }
290
+ }
291
+
292
+ return type;
293
+ });
294
+ }
295
+
280
296
Type RequirementFailure::getOwnerType () const {
281
297
auto *anchor = getRawAnchor ();
282
298
@@ -3508,19 +3524,12 @@ bool InvalidTupleSplatWithSingleParameterFailure::diagnoseAsError() {
3508
3524
return false ;
3509
3525
3510
3526
using Substitution = std::pair<GenericTypeParamType *, Type>;
3511
- llvm::SetVector<Substitution> substitutions;
3512
- auto paramTy = ParamType.transform ([&](Type type) -> Type {
3513
- if (auto *typeVar = type->getAs <TypeVariableType>()) {
3514
- type = resolveType (typeVar);
3515
-
3516
- if (auto *GP = typeVar->getImpl ().getGenericParameter ()) {
3517
- substitutions.insert (std::make_pair (GP, type));
3518
- return GP;
3519
- }
3520
- }
3527
+ llvm::DenseMap<GenericParamKey, Substitution> substitutions;
3521
3528
3522
- return type;
3523
- });
3529
+ auto paramTy = restoreGenericParameters (
3530
+ ParamType, [&](GenericTypeParamType *GP, Type resolvedType) {
3531
+ substitutions[{GP}] = std::make_pair (GP, resolvedType);
3532
+ });
3524
3533
3525
3534
DeclBaseName name = choice->getBaseName ();
3526
3535
@@ -3529,7 +3538,8 @@ bool InvalidTupleSplatWithSingleParameterFailure::diagnoseAsError() {
3529
3538
subsStr += " [where " ;
3530
3539
interleave (
3531
3540
substitutions,
3532
- [&subsStr](const Substitution &substitution) {
3541
+ [&subsStr](const std::pair<GenericParamKey, Substitution> &e) {
3542
+ const auto &substitution = e.second ;
3533
3543
subsStr += substitution.first ->getString ();
3534
3544
subsStr += " = " ;
3535
3545
subsStr += substitution.second ->getString ();
0 commit comments