Skip to content

Commit 1b976d4

Browse files
authored
Merge pull request #60410 from slavapestov/remove-already-bound-to-nominal
AST: Remove ExtensionDecl::alreadyBoundToNominal()
2 parents 68c5293 + 30c99b5 commit 1b976d4

File tree

3 files changed

+2
-15
lines changed

3 files changed

+2
-15
lines changed

include/swift/AST/Decl.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,10 +1416,6 @@ class ExtensionDecl final : public GenericContext, public Decl,
14161416

14171417
bool hasValidParent() const;
14181418

1419-
/// Determine whether this extension has already been bound to a nominal
1420-
/// type declaration.
1421-
bool alreadyBoundToNominal() const { return NextExtension.getInt(); }
1422-
14231419
/// Retrieve the extended type definition as written in the source, if it exists.
14241420
///
14251421
/// Repr would not be available if the extension was been loaded

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4384,7 +4384,7 @@ ExtensionRange NominalTypeDecl::getExtensions() {
43844384
}
43854385

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

43904390
// First extension; set both first and last.

lib/Sema/TypeChecker.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,23 +183,14 @@ ModuleDecl *TypeChecker::getStdlibModule(const DeclContext *dc) {
183183
return dc->getParentModule();
184184
}
185185

186-
/// Bind the given extension to the given nominal type.
187-
static void bindExtensionToNominal(ExtensionDecl *ext,
188-
NominalTypeDecl *nominal) {
189-
if (ext->alreadyBoundToNominal())
190-
return;
191-
192-
nominal->addExtension(ext);
193-
}
194-
195186
void swift::bindExtensions(ModuleDecl &mod) {
196187
// Utility function to try and resolve the extended type without diagnosing.
197188
// If we succeed, we go ahead and bind the extension. Otherwise, return false.
198189
auto tryBindExtension = [&](ExtensionDecl *ext) -> bool {
199190
assert(!ext->canNeverBeBound() &&
200191
"Only extensions that can ever be bound get here.");
201192
if (auto nominal = ext->computeExtendedNominal()) {
202-
bindExtensionToNominal(ext, nominal);
193+
nominal->addExtension(ext);
203194
return true;
204195
}
205196

0 commit comments

Comments
 (0)