Skip to content

Commit 2d93b21

Browse files
author
ematejska
authored
Merge pull request #10410 from DougGregor/gsb-unresolved-types-4.0
[4.0] [GSB] Record unresolved potential archetypes as delayed requirements.
2 parents 8fbb2ca + 74e05a0 commit 2d93b21

File tree

5 files changed

+204
-105
lines changed

5 files changed

+204
-105
lines changed

include/swift/AST/GenericSignatureBuilder.h

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@ class GenericSignatureBuilder {
265265
GenericSignatureBuilder(const GenericSignatureBuilder &) = delete;
266266
GenericSignatureBuilder &operator=(const GenericSignatureBuilder &) = delete;
267267

268+
/// Record that the given potential archetype is unresolved, so we know to
269+
/// resolve it later.
270+
void recordUnresolvedType(PotentialArchetype *unresolvedPA);
271+
268272
/// When a particular requirement cannot be resolved due to, e.g., a
269273
/// currently-unresolvable or nested type, this routine should be
270274
/// called to cope with the unresolved requirement.
@@ -294,6 +298,10 @@ class GenericSignatureBuilder {
294298
ProtocolDecl *Proto,
295299
const RequirementSource *Source);
296300

301+
/// Try to resolve the given unresolved potential archetype.
302+
ConstraintResult resolveUnresolvedType(PotentialArchetype *pa,
303+
bool allowTypoCorrection);
304+
297305
public:
298306
/// \brief Add a new same-type requirement between two fully resolved types
299307
/// (output of \c GenericSignatureBuilder::resolve).
@@ -1341,13 +1349,7 @@ class GenericSignatureBuilder::PotentialArchetype {
13411349

13421350
/// \brief Construct a new potential archetype for an unresolved
13431351
/// associated type.
1344-
PotentialArchetype(PotentialArchetype *parent, Identifier name)
1345-
: parentOrBuilder(parent), identifier(name), isUnresolvedNestedType(true),
1346-
IsRecursive(false), Invalid(false),
1347-
DiagnosedRename(false)
1348-
{
1349-
assert(parent != nullptr && "Not an associated type?");
1350-
}
1352+
PotentialArchetype(PotentialArchetype *parent, Identifier name);
13511353

13521354
/// \brief Construct a new potential archetype for an associated type.
13531355
PotentialArchetype(PotentialArchetype *parent, AssociatedTypeDecl *assocType)
@@ -1694,7 +1696,22 @@ class GenericSignatureBuilder::PotentialArchetype {
16941696
/// Describes a requirement whose processing has been delayed for some reason.
16951697
class GenericSignatureBuilder::DelayedRequirement {
16961698
public:
1697-
RequirementKind kind;
1699+
enum Kind {
1700+
/// A type requirement, which may be a conformance or a superclass
1701+
/// requirement.
1702+
Type,
1703+
1704+
/// A layout requirement.
1705+
Layout,
1706+
1707+
/// A same-type requirement.
1708+
SameType,
1709+
1710+
/// An unresolved potential archetype.
1711+
Unresolved,
1712+
};
1713+
1714+
Kind kind;
16981715
UnresolvedType lhs;
16991716
RequirementRHS rhs;
17001717
FloatingRequirementSource source;

0 commit comments

Comments
 (0)