Skip to content

Commit

Permalink
Fix issue 21372: remove premature deprecation check.
Browse files Browse the repository at this point in the history
Keep the check only for variable declarations.
  • Loading branch information
FeepingCreature committed Nov 9, 2020
1 parent 90d30a7 commit 2497022
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/dmd/typesem.d
Expand Up @@ -3659,12 +3659,6 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, int flag)
{
return noMember(mt, sc, e, ident, flag);
}
if (!s.isFuncDeclaration()) // because of overloading
{
s.checkDeprecated(e.loc, sc);
if (auto d = s.isDeclaration())
d.checkDisabled(e.loc, sc);
}
s = s.toAlias();

if (auto em = s.isEnumMember())
Expand All @@ -3673,6 +3667,8 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, int flag)
}
if (auto v = s.isVarDeclaration())
{
v.checkDeprecated(e.loc, sc);
v.checkDisabled(e.loc, sc);
if (!v.type ||
!v.type.deco && v.inuse)
{
Expand Down
24 changes: 24 additions & 0 deletions test/compilable/test21372.d
@@ -0,0 +1,24 @@
// REQUIRED_ARGS: -de
struct S
{
deprecated void foo(T)(int) { }
void foo(T)(string) { }
}

// just to be safe, check this order too
// (there were some issues where naive checks of overloads were order dependent)
struct T
{
void foo(T)(string) { }
deprecated void foo(T)(int) { }
}

void main()
{
// this should not hit the deprecation
// because the parameter type doesn't match it
S().foo!int("hi");

// likewise
T().foo!int("hi");
}

0 comments on commit 2497022

Please sign in to comment.