D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 22668 - Deprecation when a deprecated method overrides another deprecated method
Summary: Deprecation when a deprecated method overrides another deprecated method
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2022-01-12 13:45 UTC by moonlightsentinel
Modified: 2022-01-14 17:44 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description moonlightsentinel 2022-01-12 13:45:25 UTC
DMD issues deprecation warnings when a deprecated method overrides another deprecated method.

Example:

class A
{
    deprecated void foo() {}
}

class B
{
    deprecated override void foo() {}
    // onlineapp.d(8): Deprecation: `onlineapp.B.foo` is overriding the deprecated method `onlineapp.A.foo`
    // onlineapp.d(8): Deprecation: `onlineapp.B.foo` cannot be marked as `deprecated` because it is overriding a function in the base class
}

There's no good reason to reject that code given that both methods acknowledge that `foo` is deprecated. This is especially bad when a library wants to deprecate a method that is implemented by several different classes - the deprecation warnings should then appear in the user code but are currently triggered inside of the library.
Comment 1 Dlang Bot 2022-01-14 15:16:25 UTC
@MoonlightSentinel created dlang/dmd pull request #13533 "Fix 22668 - Don't errors when a deprecated method overrides another one" fixing this issue:

- Fix 22668 - Don't errors when a deprecated method overrides another one
  
  Because both declarations acknowledge that the declaration is deprecated.
  This is especially important for libraries that provide a collection of
  classes and want to deprecate certain method throughout the entire
  class hierarchy.

https://github.com/dlang/dmd/pull/13533
Comment 2 Dlang Bot 2022-01-14 17:44:28 UTC
dlang/dmd pull request #13533 "Fix 22668 - Don't error when a deprecated method overrides another one" was merged into master:

- eb9c1b9c071620f7f19a34401af4bf165de3cad6 by MoonlightSentinel:
  Fix 22668 - Don't errors when a deprecated method overrides another one
  
  Because both declarations acknowledge that the declaration is deprecated.
  This is especially important for libraries that provide a collection of
  classes and want to deprecate certain method throughout the entire
  class hierarchy.

https://github.com/dlang/dmd/pull/13533