Skip to content

Remove deprecated warning in synthetic def #11055

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

Closed
wants to merge 3 commits into from
Closed
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
8 changes: 5 additions & 3 deletions compiler/src/dotty/tools/dotc/typer/RefChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -902,19 +902,21 @@ object RefChecks {

def isDeprecatedOrEnum(owner: Symbol)(using Context) =
// pre: sym is an enumcase
owner.isDeprecated
isDeprecatedOrSyntheticMethod(owner)
|| isEnumOwner(owner)

def isDeprecatedOrSyntheticMethod(owner: Symbol) = owner.isDeprecated || (owner.isRealMethod && owner.is(Synthetic))

/**Scan the chain of outer declaring scopes from the current context
* a deprecation warning will be skipped if one the following holds
* for a given declaring scope:
* - the symbol associated with the scope is also deprecated.
* - the symbol associated with the scope is also deprecated or synthetic real method.
* - if and only if `sym` is an enum case, the scope is either
* a module that declares `sym`, or the companion class of the
* module that declares `sym`.
*/
def skipWarning(using Context) =
ctx.owner.ownersIterator.exists(if sym.isEnumCase then isDeprecatedOrEnum else _.isDeprecated)
ctx.owner.ownersIterator.exists(if sym.isEnumCase then isDeprecatedOrEnum else isDeprecatedOrSyntheticMethod)

for annot <- sym.getAnnotation(defn.DeprecatedAnnot) do
if !skipWarning then
Expand Down
1 change: 1 addition & 0 deletions tests/pos-special/fatal-warnings/i11022.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@deprecated("no CaseClass", "0.1") case class CaseClass(rgb: Int)