Skip to content

Commit 6340fc7

Browse files
Move Module.checkImportDeprecation to dsymbolsem (#21601)
1 parent b449c17 commit 6340fc7

3 files changed

Lines changed: 27 additions & 27 deletions

File tree

compiler/src/dmd/dmodule.d

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -955,32 +955,6 @@ extern (C++) final class Module : Package
955955
return needmoduleinfo || global.params.cov;
956956
}
957957

958-
/*******************************************
959-
* Print deprecation warning if we're deprecated, when
960-
* this module is imported from scope sc.
961-
*
962-
* Params:
963-
* sc = the scope into which we are imported
964-
* loc = the location of the import statement
965-
*/
966-
void checkImportDeprecation(Loc loc, Scope* sc)
967-
{
968-
if (md && md.isdeprecated && !sc.isDeprecated)
969-
{
970-
Expression msg = md.msg;
971-
if (StringExp se = msg ? msg.toStringExp() : null)
972-
{
973-
const slice = se.peekString();
974-
if (slice.length)
975-
{
976-
deprecation(loc, "%s `%s` is deprecated - %.*s", kind, toPrettyChars, cast(int)slice.length, slice.ptr);
977-
return;
978-
}
979-
}
980-
deprecation(loc, "%s `%s` is deprecated", kind, toPrettyChars);
981-
}
982-
}
983-
984958
override bool isPackageAccessible(Package p, Visibility visibility, SearchOptFlags flags = SearchOpt.all)
985959
{
986960
if (insearch) // don't follow import cycles

compiler/src/dmd/dsymbolsem.d

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,33 @@ Ungag ungagSpeculative(const Dsymbol s)
454454
return Ungag(oldgag);
455455
}
456456

457+
/*******************************************
458+
* Print deprecation warning if we're deprecated, when
459+
* this module is imported from scope sc.
460+
*
461+
* Params:
462+
* m = the module
463+
* sc = the scope into which we are imported
464+
* loc = the location of the import statement
465+
*/
466+
private void checkImportDeprecation(Module m, Loc loc, Scope* sc)
467+
{
468+
if (!m.md || !m.md.isdeprecated || sc.isDeprecated)
469+
return;
470+
471+
Expression msg = m.md.msg;
472+
if (StringExp se = msg ? msg.toStringExp() : null)
473+
{
474+
const slice = se.peekString();
475+
if (slice.length)
476+
{
477+
deprecation(m.loc, "%s `%s` is deprecated - %.*s", m.kind, m.toPrettyChars, cast(int)slice.length, slice.ptr);
478+
return;
479+
}
480+
}
481+
deprecation(m.loc, "%s `%s` is deprecated", m.kind, m.toPrettyChars);
482+
}
483+
457484
private extern(C++) final class DsymbolSemanticVisitor : Visitor
458485
{
459486
alias visit = Visitor.visit;

compiler/src/dmd/frontend.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7210,7 +7210,6 @@ class Module final : public Package
72107210
bool read(Loc loc);
72117211
Module* parse();
72127212
int32_t needModuleInfo();
7213-
void checkImportDeprecation(Loc loc, Scope* sc);
72147213
bool isPackageAccessible(Package* p, Visibility visibility, uint32_t flags = 0u) override;
72157214
Dsymbol* symtabInsert(Dsymbol* s) override;
72167215
static void runDeferredSemantic();

0 commit comments

Comments
 (0)