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