@@ -68,9 +68,6 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
68
68
// Keep track of acceptable DiscardAssignmentExpr's.
69
69
SmallPtrSet<DiscardAssignmentExpr*, 2 > CorrectDiscardAssignmentExprs;
70
70
71
- // / Keep track of InOutExprs
72
- SmallPtrSet<InOutExpr*, 2 > AcceptableInOutExprs;
73
-
74
71
// / Keep track of the arguments to CallExprs.
75
72
SmallPtrSet<Expr *, 2 > CallArgs;
76
73
@@ -127,15 +124,9 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
127
124
if (isa<TypeExpr>(Base))
128
125
checkUseOfMetaTypeName (Base);
129
126
130
- if (auto *SE = dyn_cast<SubscriptExpr>(E)) {
127
+ if (auto *SE = dyn_cast<SubscriptExpr>(E))
131
128
CallArgs.insert (SE->getIndex ());
132
129
133
- // Implicit InOutExpr's are allowed in the base of a subscript expr.
134
- if (auto *IOE = dyn_cast<InOutExpr>(SE->getBase ()))
135
- if (IOE->isImplicit ())
136
- AcceptableInOutExprs.insert (IOE);
137
- }
138
-
139
130
if (auto *KPE = dyn_cast<KeyPathExpr>(E)) {
140
131
for (auto Comp : KPE->getComponents ()) {
141
132
if (auto *Arg = Comp.getIndexExpr ())
@@ -197,11 +188,6 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
197
188
}
198
189
199
190
visitArguments (Call, [&](unsigned argIndex, Expr *arg) {
200
- // InOutExpr's are allowed in argument lists directly.
201
- if (auto *IOE = dyn_cast<InOutExpr>(arg)) {
202
- if (isa<CallExpr>(Call))
203
- AcceptableInOutExprs.insert (IOE);
204
- }
205
191
// InOutExprs can be wrapped in some implicit casts.
206
192
Expr *unwrapped = arg;
207
193
if (auto *IIO = dyn_cast<InjectIntoOptionalExpr>(arg))
@@ -212,10 +198,8 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
212
198
isa<ErasureExpr>(unwrapped)) {
213
199
auto operand =
214
200
cast<ImplicitConversionExpr>(unwrapped)->getSubExpr ();
215
- if (auto *IOE = dyn_cast<InOutExpr>(operand)) {
216
- AcceptableInOutExprs.insert (IOE);
201
+ if (auto *IOE = dyn_cast<InOutExpr>(operand))
217
202
operand = IOE->getSubExpr ();
218
- }
219
203
220
204
// Also do some additional work based on how the function uses
221
205
// the argument.
@@ -238,14 +222,6 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
238
222
TC.diagnose (DAE->getLoc (), diag::discard_expr_outside_of_assignment);
239
223
}
240
224
241
- // Diagnose an '&' that isn't in an argument lists.
242
- if (auto *IOE = dyn_cast<InOutExpr>(E)) {
243
- if (!IOE->isImplicit () && !AcceptableInOutExprs.count (IOE) &&
244
- !IOE->getType ()->hasError ())
245
- TC.diagnose (IOE->getLoc (), diag::inout_expr_outside_of_call)
246
- .highlight (IOE->getSubExpr ()->getSourceRange ());
247
- }
248
-
249
225
// Diagnose 'self.init' or 'super.init' nested in another expression
250
226
// or closure.
251
227
if (auto *rebindSelfExpr = dyn_cast<RebindSelfInConstructorExpr>(E)) {
0 commit comments