@@ -424,10 +424,6 @@ static bool shouldShowAKA(Type type, StringRef typeName) {
424
424
if (type->isCanonical ())
425
425
return false ;
426
426
427
- // Don't show generic type parameters.
428
- if (type->getCanonicalType ()->hasTypeParameter ())
429
- return false ;
430
-
431
427
// Only show 'aka' if there's a typealias involved; other kinds of sugar
432
428
// are easy enough for people to read on their own.
433
429
if (!type.findIf (isInterestingTypealias))
@@ -459,6 +455,20 @@ static bool typeSpellingIsAmbiguous(Type type,
459
455
return false ;
460
456
}
461
457
458
+ // / Walks the type recursivelly desugaring types to display, but skiping
459
+ // / `GenericTypeParamType` because we would lose association with it's original
460
+ // / declaration and end up presenting the parameter in τ_0_0 format on
461
+ // / diagnostic.
462
+ static Type getAkaTypeForDisplay (Type type) {
463
+ auto Func = [](Type visitTy) -> Type {
464
+ if (isa<SugarType>(visitTy.getPointer ()) &&
465
+ !isa<GenericTypeParamType>(visitTy.getPointer ()))
466
+ return getAkaTypeForDisplay (visitTy->getDesugaredType ());
467
+ return visitTy;
468
+ };
469
+ return type.transform (Func).getPointer ();
470
+ }
471
+
462
472
// / Format a single diagnostic argument and write it to the given
463
473
// / stream.
464
474
static void formatDiagnosticArgument (StringRef Modifier,
@@ -577,7 +587,8 @@ static void formatDiagnosticArgument(StringRef Modifier,
577
587
if (shouldShowAKA (type, typeName)) {
578
588
llvm::SmallString<256 > AkaText;
579
589
llvm::raw_svector_ostream OutAka (AkaText);
580
- OutAka << type->getCanonicalType ();
590
+
591
+ OutAka << getAkaTypeForDisplay (type);
581
592
Out << llvm::format (FormatOpts.AKAFormatString .c_str (),
582
593
typeName.c_str (), AkaText.c_str ());
583
594
} else {
0 commit comments