Skip to content

[4.0] [GSB] Record unresolved potential archetypes as delayed requirements. #10410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions include/swift/AST/GenericSignatureBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ class GenericSignatureBuilder {
GenericSignatureBuilder(const GenericSignatureBuilder &) = delete;
GenericSignatureBuilder &operator=(const GenericSignatureBuilder &) = delete;

/// Record that the given potential archetype is unresolved, so we know to
/// resolve it later.
void recordUnresolvedType(PotentialArchetype *unresolvedPA);

/// When a particular requirement cannot be resolved due to, e.g., a
/// currently-unresolvable or nested type, this routine should be
/// called to cope with the unresolved requirement.
Expand Down Expand Up @@ -294,6 +298,10 @@ class GenericSignatureBuilder {
ProtocolDecl *Proto,
const RequirementSource *Source);

/// Try to resolve the given unresolved potential archetype.
ConstraintResult resolveUnresolvedType(PotentialArchetype *pa,
bool allowTypoCorrection);

public:
/// \brief Add a new same-type requirement between two fully resolved types
/// (output of \c GenericSignatureBuilder::resolve).
Expand Down Expand Up @@ -1341,13 +1349,7 @@ class GenericSignatureBuilder::PotentialArchetype {

/// \brief Construct a new potential archetype for an unresolved
/// associated type.
PotentialArchetype(PotentialArchetype *parent, Identifier name)
: parentOrBuilder(parent), identifier(name), isUnresolvedNestedType(true),
IsRecursive(false), Invalid(false),
DiagnosedRename(false)
{
assert(parent != nullptr && "Not an associated type?");
}
PotentialArchetype(PotentialArchetype *parent, Identifier name);

/// \brief Construct a new potential archetype for an associated type.
PotentialArchetype(PotentialArchetype *parent, AssociatedTypeDecl *assocType)
Expand Down Expand Up @@ -1694,7 +1696,22 @@ class GenericSignatureBuilder::PotentialArchetype {
/// Describes a requirement whose processing has been delayed for some reason.
class GenericSignatureBuilder::DelayedRequirement {
public:
RequirementKind kind;
enum Kind {
/// A type requirement, which may be a conformance or a superclass
/// requirement.
Type,

/// A layout requirement.
Layout,

/// A same-type requirement.
SameType,

/// An unresolved potential archetype.
Unresolved,
};

Kind kind;
UnresolvedType lhs;
RequirementRHS rhs;
FloatingRequirementSource source;
Expand Down
Loading