Skip to content

AST: Remove ExtensionDecl::alreadyBoundToNominal() #60410

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
4 changes: 0 additions & 4 deletions include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1416,10 +1416,6 @@ class ExtensionDecl final : public GenericContext, public Decl,

bool hasValidParent() const;

/// Determine whether this extension has already been bound to a nominal
/// type declaration.
bool alreadyBoundToNominal() const { return NextExtension.getInt(); }

/// Retrieve the extended type definition as written in the source, if it exists.
///
/// Repr would not be available if the extension was been loaded
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4384,7 +4384,7 @@ ExtensionRange NominalTypeDecl::getExtensions() {
}

void NominalTypeDecl::addExtension(ExtensionDecl *extension) {
assert(!extension->alreadyBoundToNominal() && "Already added extension");
assert(!extension->NextExtension.getInt() && "Already added extension");
extension->NextExtension.setInt(true);

// First extension; set both first and last.
Expand Down
11 changes: 1 addition & 10 deletions lib/Sema/TypeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,23 +183,14 @@ ModuleDecl *TypeChecker::getStdlibModule(const DeclContext *dc) {
return dc->getParentModule();
}

/// Bind the given extension to the given nominal type.
static void bindExtensionToNominal(ExtensionDecl *ext,
NominalTypeDecl *nominal) {
if (ext->alreadyBoundToNominal())
return;

nominal->addExtension(ext);
}

void swift::bindExtensions(ModuleDecl &mod) {
// Utility function to try and resolve the extended type without diagnosing.
// If we succeed, we go ahead and bind the extension. Otherwise, return false.
auto tryBindExtension = [&](ExtensionDecl *ext) -> bool {
assert(!ext->canNeverBeBound() &&
"Only extensions that can ever be bound get here.");
if (auto nominal = ext->computeExtendedNominal()) {
bindExtensionToNominal(ext, nominal);
nominal->addExtension(ext);
return true;
}

Expand Down