@@ -74,7 +74,24 @@ namespace swift {
74
74
typedef T type;
75
75
};
76
76
}
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
+
78
95
// / Describes the kind of diagnostic argument we're storing.
79
96
// /
80
97
enum class DiagnosticArgumentKind {
@@ -86,6 +103,7 @@ namespace swift {
86
103
ValueDecl,
87
104
Type,
88
105
TypeRepr,
106
+ FullyQualifiedType,
89
107
PatternKind,
90
108
SelfAccessKind,
91
109
ReferenceOwnership,
@@ -116,6 +134,7 @@ namespace swift {
116
134
ValueDecl *TheValueDecl;
117
135
Type TypeVal;
118
136
TypeRepr *TyR;
137
+ FullyQualified<Type> FullyQualifiedTypeVal;
119
138
PatternKind PatternKindVal;
120
139
SelfAccessKind SelfAccessKindVal;
121
140
ReferenceOwnership ReferenceOwnershipVal;
@@ -172,6 +191,10 @@ namespace swift {
172
191
: Kind(DiagnosticArgumentKind::TypeRepr), TyR(T) {
173
192
}
174
193
194
+ DiagnosticArgument (FullyQualified<Type> FQT)
195
+ : Kind(DiagnosticArgumentKind::FullyQualifiedType),
196
+ FullyQualifiedTypeVal(FQT) {}
197
+
175
198
DiagnosticArgument (const TypeLoc &TL) {
176
199
if (TypeRepr *tyR = TL.getTypeRepr ()) {
177
200
Kind = DiagnosticArgumentKind::TypeRepr;
@@ -268,7 +291,12 @@ namespace swift {
268
291
assert (Kind == DiagnosticArgumentKind::TypeRepr);
269
292
return TyR;
270
293
}
271
-
294
+
295
+ FullyQualified<Type> getAsFullyQualifiedType () const {
296
+ assert (Kind == DiagnosticArgumentKind::FullyQualifiedType);
297
+ return FullyQualifiedTypeVal;
298
+ }
299
+
272
300
PatternKind getAsPatternKind () const {
273
301
assert (Kind == DiagnosticArgumentKind::PatternKind);
274
302
return PatternKindVal;
0 commit comments