@@ -525,6 +525,14 @@ struct GenericSignatureBuilder::ResolvedType {
525
525
return ResolvedType (t);
526
526
}
527
527
528
+ // FIXME: this probably shouldn't exist, the potential archetype modelling of
529
+ // generic typealiases is fundamentally broken (aka they're not modelled at
530
+ // all), but some things with them mostly work, so we just maintain that,
531
+ // despite this causing crashes and weird behaviour.
532
+ static ResolvedType forConcreteTypeFromGenericTypeAlias (Type t) {
533
+ return ResolvedType (t);
534
+ }
535
+
528
536
static ResolvedType forPotentialArchetype (PotentialArchetype *pa) {
529
537
assert (!(pa->getParent () && pa->getTypeAliasDecl ()) &&
530
538
" typealias is only considered resolved when new" );
@@ -1347,12 +1355,17 @@ auto GenericSignatureBuilder::resolveArchetype(Type type) -> PotentialArchetype
1347
1355
return nullptr ;
1348
1356
}
1349
1357
1350
- auto GenericSignatureBuilder::resolve (UnresolvedType paOrT) -> ResolvedType {
1358
+ auto GenericSignatureBuilder::resolve (UnresolvedType paOrT,
1359
+ bool hackTypeFromGenericTypeAlias)
1360
+ -> ResolvedType {
1351
1361
auto pa = paOrT.dyn_cast <PotentialArchetype *>();
1352
1362
if (auto type = paOrT.dyn_cast <Type>()) {
1353
1363
pa = resolveArchetype (type);
1354
- if (!pa)
1364
+ if (!pa) {
1365
+ if (hackTypeFromGenericTypeAlias)
1366
+ return ResolvedType::forConcreteTypeFromGenericTypeAlias (type);
1355
1367
return ResolvedType::forConcreteType (type);
1368
+ }
1356
1369
}
1357
1370
1358
1371
pa = pa->getRepresentative ();
@@ -1370,12 +1383,17 @@ auto GenericSignatureBuilder::resolve(UnresolvedType paOrT) -> ResolvedType {
1370
1383
// The right-hand side of the typealias could itself be an archetype
1371
1384
// (e.g. protocol P { associatedtype A; typealias B = A }), so we need to
1372
1385
// resolve that. However, the archetype should always be resolved far enough
1373
- // upon creation to not be another type alias (verified by the assertion
1374
- // below), and hence this function doesn't need to be recursive. .
1386
+ // upon creation to not be another type alias (verified by the ResolvedType
1387
+ // constructors below), and hence this function doesn't need to be recursive.
1375
1388
auto concrete = pa->getConcreteType ();
1376
1389
auto rhsPA = resolveArchetype (concrete);
1377
- if (!rhsPA)
1390
+ if (!rhsPA) {
1391
+ // FIXME: same as hackTypeFromGenericTypeAlias
1392
+ if (pa->getTypeAliasDecl ()->getGenericParams ())
1393
+ return ResolvedType::forConcreteTypeFromGenericTypeAlias (concrete);
1394
+
1378
1395
return ResolvedType::forConcreteType (concrete);
1396
+ }
1379
1397
1380
1398
return ResolvedType::forPotentialArchetype (rhsPA);
1381
1399
}
0 commit comments