@@ -1218,25 +1218,8 @@ namespace {
1218
1218
return finish (true , expr);
1219
1219
}
1220
1220
1221
- if (auto unresolved = dyn_cast<UnresolvedDeclRefExpr>(expr)) {
1222
- auto *refExpr = TypeChecker::resolveDeclRefExpr (unresolved, DC);
1223
-
1224
- // Check whether this is standalone `self` in init accessor, which
1225
- // is invalid.
1226
- if (auto *accessor = DC->getInnermostPropertyAccessorContext ()) {
1227
- if (accessor->isInitAccessor () && isa<DeclRefExpr>(refExpr)) {
1228
- auto *DRE = cast<DeclRefExpr>(refExpr);
1229
- if (accessor->getImplicitSelfDecl () == DRE->getDecl () &&
1230
- !isa_and_nonnull<UnresolvedDotExpr>(Parent.getAsExpr ())) {
1231
- diags.diagnose (unresolved->getLoc (),
1232
- diag::invalid_use_of_self_in_init_accessor);
1233
- refExpr = new (Ctx) ErrorExpr (unresolved->getSourceRange ());
1234
- }
1235
- }
1236
- }
1237
-
1238
- return finish (true , refExpr);
1239
- }
1221
+ if (auto *unresolved = dyn_cast<UnresolvedDeclRefExpr>(expr))
1222
+ return finish (true , TypeChecker::resolveDeclRefExpr (unresolved, DC));
1240
1223
1241
1224
// Let's try to figure out if `InOutExpr` is out of place early
1242
1225
// otherwise there is a risk of producing solutions which can't
@@ -1325,7 +1308,22 @@ namespace {
1325
1308
if (auto *typeExpr = simplifyUnresolvedSpecializeExpr (us))
1326
1309
return Action::Continue (typeExpr);
1327
1310
}
1328
-
1311
+
1312
+ // Check whether this is standalone `self` in init accessor, which
1313
+ // is invalid.
1314
+ if (auto *DRE = dyn_cast<DeclRefExpr>(expr)) {
1315
+ if (auto *accessor = DC->getInnermostPropertyAccessorContext ()) {
1316
+ if (accessor->isInitAccessor ()) {
1317
+ if (accessor->getImplicitSelfDecl () == DRE->getDecl () &&
1318
+ !isa_and_nonnull<UnresolvedDotExpr>(Parent.getAsExpr ())) {
1319
+ Ctx.Diags .diagnose (DRE->getLoc (),
1320
+ diag::invalid_use_of_self_in_init_accessor);
1321
+ return Action::Continue (new (Ctx) ErrorExpr (DRE->getSourceRange ()));
1322
+ }
1323
+ }
1324
+ }
1325
+ }
1326
+
1329
1327
// If we're about to step out of a ClosureExpr, restore the DeclContext.
1330
1328
if (auto *ce = dyn_cast<ClosureExpr>(expr)) {
1331
1329
assert (DC == ce && " DeclContext imbalance" );
0 commit comments