@@ -160,8 +160,8 @@ class GenericSignatureBuilder {
160
160
// / Describes a component within the graph of same-type constraints within
161
161
// / the equivalence class that is held together by derived constraints.
162
162
struct DerivedSameTypeComponent {
163
- // / The potential archetype that acts as the anchor for this component.
164
- UnresolvedType anchor ;
163
+ // / The type that acts as the anchor for this component.
164
+ Type type ;
165
165
166
166
// / The (best) requirement source within the component that makes the
167
167
// / potential archetypes in this component equivalent to the concrete
@@ -1477,31 +1477,17 @@ struct GenericSignatureBuilder::Constraint {
1477
1477
};
1478
1478
1479
1479
class GenericSignatureBuilder ::PotentialArchetype {
1480
- // / The parent of this potential archetype (for a nested type) or the
1481
- // / ASTContext in which the potential archetype resides.
1482
- llvm::PointerUnion<PotentialArchetype*, ASTContext*> parentOrContext;
1483
-
1484
- // / The identifier describing this particular archetype.
1485
- // /
1486
- // / \c parentOrBuilder determines whether we have a nested type vs. a root.
1487
- union PAIdentifier {
1488
- // / The associated type for a resolved nested type.
1489
- AssociatedTypeDecl *assocType;
1490
-
1491
- // / The generic parameter key for a root.
1492
- GenericParamKey genericParam;
1493
-
1494
- PAIdentifier (AssociatedTypeDecl *assocType) : assocType (assocType) {}
1495
-
1496
- PAIdentifier (GenericParamKey genericParam) : genericParam (genericParam) { }
1497
- } identifier;
1480
+ // / The parent of this potential archetype, for a nested type.
1481
+ PotentialArchetype* parent;
1498
1482
1499
1483
// / The representative of the equivalence class of potential archetypes
1500
1484
// / to which this potential archetype belongs, or (for the representative)
1501
1485
// / the equivalence class itself.
1502
1486
mutable llvm::PointerUnion<PotentialArchetype *, EquivalenceClass *>
1503
1487
representativeOrEquivClass;
1504
1488
1489
+ mutable CanType depType;
1490
+
1505
1491
// / A stored nested type.
1506
1492
struct StoredNestedType {
1507
1493
// / The potential archetypes describing this nested type, all of which
@@ -1539,7 +1525,7 @@ class GenericSignatureBuilder::PotentialArchetype {
1539
1525
PotentialArchetype (PotentialArchetype *parent, AssociatedTypeDecl *assocType);
1540
1526
1541
1527
// / Construct a new potential archetype for a generic parameter.
1542
- PotentialArchetype (ASTContext &ctx, GenericParamKey genericParam);
1528
+ explicit PotentialArchetype (GenericTypeParamType * genericParam);
1543
1529
1544
1530
public:
1545
1531
// / Retrieve the representative for this archetype, performing
@@ -1558,42 +1544,17 @@ class GenericSignatureBuilder::PotentialArchetype {
1558
1544
// / Retrieve the parent of this potential archetype, which will be non-null
1559
1545
// / when this potential archetype is an associated type.
1560
1546
PotentialArchetype *getParent () const {
1561
- return parentOrContext. dyn_cast <PotentialArchetype *>() ;
1547
+ return parent ;
1562
1548
}
1563
1549
1564
1550
// / Retrieve the type declaration to which this nested type was resolved.
1565
1551
AssociatedTypeDecl *getResolvedType () const {
1566
- assert (getParent () && " Not an associated type" );
1567
- return identifier.assocType ;
1552
+ return cast<DependentMemberType>(depType)->getAssocType ();
1568
1553
}
1569
1554
1570
1555
// / Determine whether this is a generic parameter.
1571
1556
bool isGenericParam () const {
1572
- return parentOrContext.is <ASTContext *>();
1573
- }
1574
-
1575
- // / Retrieve the generic parameter key for a potential archetype that
1576
- // / represents this potential archetype.
1577
- // /
1578
- // / \pre \c isGenericParam()
1579
- GenericParamKey getGenericParamKey () const {
1580
- assert (isGenericParam () && " Not a generic parameter" );
1581
- return identifier.genericParam ;
1582
- }
1583
-
1584
- // / Retrieve the generic parameter key for the generic parameter at the
1585
- // / root of this potential archetype.
1586
- GenericParamKey getRootGenericParamKey () const {
1587
- if (auto parent = getParent ())
1588
- return parent->getRootGenericParamKey ();
1589
-
1590
- return getGenericParamKey ();
1591
- }
1592
-
1593
- // / Retrieve the name of a nested potential archetype.
1594
- Identifier getNestedName () const {
1595
- assert (getParent () && " Not a nested type" );
1596
- return identifier.assocType ->getName ();
1557
+ return parent == nullptr ;
1597
1558
}
1598
1559
1599
1560
// / Retrieve the set of nested types.
@@ -1643,12 +1604,18 @@ class GenericSignatureBuilder::PotentialArchetype {
1643
1604
AssociatedTypeDecl *assocType,
1644
1605
ArchetypeResolutionKind kind);
1645
1606
1607
+ // / Retrieve the dependent type that describes this potential
1608
+ // / archetype.
1609
+ CanType getDependentType () const {
1610
+ return depType;
1611
+ }
1612
+
1646
1613
// / Retrieve the dependent type that describes this potential
1647
1614
// / archetype.
1648
1615
// /
1649
1616
// / \param genericParams The set of generic parameters to use in the resulting
1650
1617
// / dependent type.
1651
- Type getDependentType (TypeArrayView<GenericTypeParamType> genericParams)const ;
1618
+ Type getDependentType (TypeArrayView<GenericTypeParamType> genericParams) const ;
1652
1619
1653
1620
// / True if the potential archetype has been bound by a concrete type
1654
1621
// / constraint.
@@ -1659,9 +1626,6 @@ class GenericSignatureBuilder::PotentialArchetype {
1659
1626
return false ;
1660
1627
}
1661
1628
1662
- // / Retrieve the AST context in which this potential archetype resides.
1663
- ASTContext &getASTContext () const ;
1664
-
1665
1629
SWIFT_DEBUG_DUMP;
1666
1630
1667
1631
void dump (llvm::raw_ostream &Out, SourceManager *SrcMgr,
0 commit comments