@@ -74,7 +74,24 @@ namespace swift {
7474 typedef T type;
7575 };
7676 }
77-
77+
78+ // / A family of wrapper types for compiler data types that forces its
79+ // / underlying data to be formatted with full qualification.
80+ // /
81+ // / So far, this is only useful for \c Type, hence the SFINAE'ing.
82+ template <typename T, typename = void > struct FullyQualified {};
83+
84+ template <typename T>
85+ struct FullyQualified <
86+ T, typename std::enable_if<std::is_convertible<T, Type>::value>::type> {
87+ Type t;
88+
89+ public:
90+ FullyQualified (T t) : t(t){};
91+
92+ Type getType () const { return t; }
93+ };
94+
7895 // / Describes the kind of diagnostic argument we're storing.
7996 // /
8097 enum class DiagnosticArgumentKind {
@@ -86,6 +103,7 @@ namespace swift {
86103 ValueDecl,
87104 Type,
88105 TypeRepr,
106+ FullyQualifiedType,
89107 PatternKind,
90108 SelfAccessKind,
91109 ReferenceOwnership,
@@ -116,6 +134,7 @@ namespace swift {
116134 ValueDecl *TheValueDecl;
117135 Type TypeVal;
118136 TypeRepr *TyR;
137+ FullyQualified<Type> FullyQualifiedTypeVal;
119138 PatternKind PatternKindVal;
120139 SelfAccessKind SelfAccessKindVal;
121140 ReferenceOwnership ReferenceOwnershipVal;
@@ -172,6 +191,10 @@ namespace swift {
172191 : Kind(DiagnosticArgumentKind::TypeRepr), TyR(T) {
173192 }
174193
194+ DiagnosticArgument (FullyQualified<Type> FQT)
195+ : Kind(DiagnosticArgumentKind::FullyQualifiedType),
196+ FullyQualifiedTypeVal(FQT) {}
197+
175198 DiagnosticArgument (const TypeLoc &TL) {
176199 if (TypeRepr *tyR = TL.getTypeRepr ()) {
177200 Kind = DiagnosticArgumentKind::TypeRepr;
@@ -268,7 +291,12 @@ namespace swift {
268291 assert (Kind == DiagnosticArgumentKind::TypeRepr);
269292 return TyR;
270293 }
271-
294+
295+ FullyQualified<Type> getAsFullyQualifiedType () const {
296+ assert (Kind == DiagnosticArgumentKind::FullyQualifiedType);
297+ return FullyQualifiedTypeVal;
298+ }
299+
272300 PatternKind getAsPatternKind () const {
273301 assert (Kind == DiagnosticArgumentKind::PatternKind);
274302 return PatternKindVal;
0 commit comments