@@ -121,47 +121,49 @@ void RequirementRepr::dump() const {
121
121
llvm::errs () << " \n " ;
122
122
}
123
123
124
- void RequirementRepr::printImpl (ASTPrinter &out, bool AsWritten) const {
125
- auto printTy = [&](const TypeLoc &TyLoc) {
126
- if (AsWritten && TyLoc.getTypeRepr ()) {
127
- TyLoc.getTypeRepr ()->print (out, PrintOptions ());
128
- } else {
129
- TyLoc.getType ().print (out, PrintOptions ());
130
- }
131
- };
132
-
124
+ void RequirementRepr::printImpl (ASTPrinter &out) const {
133
125
auto printLayoutConstraint =
134
126
[&](const LayoutConstraintLoc &LayoutConstraintLoc) {
135
127
LayoutConstraintLoc.getLayoutConstraint ()->print (out, PrintOptions ());
136
128
};
137
129
138
130
switch (getKind ()) {
139
131
case RequirementReprKind::LayoutConstraint:
140
- printTy (getSubjectLoc ());
132
+ if (auto *repr = getSubjectRepr ()) {
133
+ repr->print (out, PrintOptions ());
134
+ }
141
135
out << " : " ;
142
136
printLayoutConstraint (getLayoutConstraintLoc ());
143
137
break ;
144
138
145
139
case RequirementReprKind::TypeConstraint:
146
- printTy (getSubjectLoc ());
140
+ if (auto *repr = getSubjectRepr ()) {
141
+ repr->print (out, PrintOptions ());
142
+ }
147
143
out << " : " ;
148
- printTy (getConstraintLoc ());
144
+ if (auto *repr = getConstraintRepr ()) {
145
+ repr->print (out, PrintOptions ());
146
+ }
149
147
break ;
150
148
151
149
case RequirementReprKind::SameType:
152
- printTy (getFirstTypeLoc ());
150
+ if (auto *repr = getFirstTypeRepr ()) {
151
+ repr->print (out, PrintOptions ());
152
+ }
153
153
out << " == " ;
154
- printTy (getSecondTypeLoc ());
154
+ if (auto *repr = getSecondTypeRepr ()) {
155
+ repr->print (out, PrintOptions ());
156
+ }
155
157
break ;
156
158
}
157
159
}
158
160
159
161
void RequirementRepr::print (raw_ostream &out) const {
160
162
StreamPrinter printer (out);
161
- printImpl (printer, /* AsWritten= */ true );
163
+ printImpl (printer);
162
164
}
163
165
void RequirementRepr::print (ASTPrinter &out) const {
164
- printImpl (out, /* AsWritten= */ true );
166
+ printImpl (out);
165
167
}
166
168
167
169
static void printTrailingRequirements (ASTPrinter &Printer,
0 commit comments