@@ -502,6 +502,19 @@ static bool isInterestingTypealias(Type type) {
502
502
return true ;
503
503
}
504
504
505
+ // / Walks the type recursivelly desugaring types to display, but skipping
506
+ // / `GenericTypeParamType` because we would lose association with its original
507
+ // / declaration and end up presenting the parameter in τ_0_0 format on
508
+ // / diagnostic.
509
+ static Type getAkaTypeForDisplay (Type type) {
510
+ return type.transform ([](Type visitTy) -> Type {
511
+ if (isa<SugarType>(visitTy.getPointer ()) &&
512
+ !isa<GenericTypeParamType>(visitTy.getPointer ()))
513
+ return getAkaTypeForDisplay (visitTy->getDesugaredType ());
514
+ return visitTy;
515
+ });
516
+ }
517
+
505
518
// / Decide whether to show the desugared type or not. We filter out some
506
519
// / cases to avoid too much noise.
507
520
static bool shouldShowAKA (Type type, StringRef typeName) {
@@ -517,7 +530,7 @@ static bool shouldShowAKA(Type type, StringRef typeName) {
517
530
// If they are textually the same, don't show them. This can happen when
518
531
// they are actually different types, because they exist in different scopes
519
532
// (e.g. everyone names their type parameters 'T').
520
- if (typeName == type-> getCanonicalType ()-> getString ())
533
+ if (typeName == getAkaTypeForDisplay (type). getString ())
521
534
return false ;
522
535
523
536
return true ;
@@ -532,7 +545,7 @@ static bool typeSpellingIsAmbiguous(Type type,
532
545
for (auto arg : Args) {
533
546
if (arg.getKind () == DiagnosticArgumentKind::Type) {
534
547
auto argType = arg.getAsType ();
535
- if (argType && ! argType->isEqual ( type) &&
548
+ if (argType && argType->getWithoutParens (). getPointer () != type. getPointer ( ) &&
536
549
argType->getWithoutParens ().getString (PO) == type.getString (PO)) {
537
550
return true ;
538
551
}
@@ -541,19 +554,6 @@ static bool typeSpellingIsAmbiguous(Type type,
541
554
return false ;
542
555
}
543
556
544
- // / Walks the type recursivelly desugaring types to display, but skipping
545
- // / `GenericTypeParamType` because we would lose association with its original
546
- // / declaration and end up presenting the parameter in τ_0_0 format on
547
- // / diagnostic.
548
- static Type getAkaTypeForDisplay (Type type) {
549
- return type.transform ([](Type visitTy) -> Type {
550
- if (isa<SugarType>(visitTy.getPointer ()) &&
551
- !isa<GenericTypeParamType>(visitTy.getPointer ()))
552
- return getAkaTypeForDisplay (visitTy->getDesugaredType ());
553
- return visitTy;
554
- });
555
- }
556
-
557
557
// / Determine whether this is the main actor type.
558
558
static bool isMainActor (Type type) {
559
559
if (auto nominal = type->getAnyNominal ()) {
0 commit comments