@@ -1303,27 +1303,6 @@ resolveTopLevelIdentTypeComponent(TypeResolution resolution,
1303
1303
auto DC = resolution.getDeclContext ();
1304
1304
auto id = comp->getNameRef ();
1305
1305
1306
- // Dynamic 'Self' in the result type of a function body.
1307
- if (id.isSimpleName (ctx.Id_Self )) {
1308
- if (auto *typeDC = DC->getInnermostTypeContext ()) {
1309
- // FIXME: The passed-in TypeRepr should get 'typechecked' as well.
1310
- // The issue is though that ComponentIdentTypeRepr only accepts a ValueDecl
1311
- // while the 'Self' type is more than just a reference to a TypeDecl.
1312
- auto selfType = resolution.mapTypeIntoContext (
1313
- typeDC->getSelfInterfaceType ());
1314
-
1315
- // Check if we can reference Self here, and if so, what kind of Self it is.
1316
- switch (getSelfTypeKind (DC, options)) {
1317
- case SelfTypeKind::StaticSelf:
1318
- return selfType;
1319
- case SelfTypeKind::DynamicSelf:
1320
- return DynamicSelfType::get (selfType, ctx);
1321
- case SelfTypeKind::InvalidSelf:
1322
- break ;
1323
- }
1324
- }
1325
- }
1326
-
1327
1306
NameLookupOptions lookupOptions = defaultUnqualifiedLookupOptions;
1328
1307
if (options.contains (TypeResolutionFlags::KnownNonCascadingDependency))
1329
1308
lookupOptions |= NameLookupFlags::KnownPrivate;
@@ -1380,6 +1359,27 @@ resolveTopLevelIdentTypeComponent(TypeResolution resolution,
1380
1359
1381
1360
// If we found nothing, complain and give ourselves a chance to recover.
1382
1361
if (current.isNull ()) {
1362
+ // Dynamic 'Self' in the result type of a function body.
1363
+ if (id.isSimpleName (ctx.Id_Self )) {
1364
+ if (auto *typeDC = DC->getInnermostTypeContext ()) {
1365
+ // FIXME: The passed-in TypeRepr should get 'typechecked' as well.
1366
+ // The issue is though that ComponentIdentTypeRepr only accepts a ValueDecl
1367
+ // while the 'Self' type is more than just a reference to a TypeDecl.
1368
+ auto selfType = resolution.mapTypeIntoContext (
1369
+ typeDC->getSelfInterfaceType ());
1370
+
1371
+ // Check if we can reference Self here, and if so, what kind of Self it is.
1372
+ switch (getSelfTypeKind (DC, options)) {
1373
+ case SelfTypeKind::StaticSelf:
1374
+ return selfType;
1375
+ case SelfTypeKind::DynamicSelf:
1376
+ return DynamicSelfType::get (selfType, ctx);
1377
+ case SelfTypeKind::InvalidSelf:
1378
+ break ;
1379
+ }
1380
+ }
1381
+ }
1382
+
1383
1383
// If we're not allowed to complain or we couldn't fix the
1384
1384
// source, bail out.
1385
1385
if (options.contains (TypeResolutionFlags::SilenceErrors))
0 commit comments