11

I have a private methods in some low level classes that are not currently in use, but I don't want the "Method x is never used" warning potentially obscuring other more important warnings. I added a standard warning suppression for that method:

    @SuppressWarnings("unused")

Up until recently that was working fine, no warning for that method. After upgrading to AS 4.1.1, however, these have started to get a "Redundant suppression" warning. If I remove the suppression the original unused warning comes back.

I'm using Android Studio 4.1.1 (Nov. 4)

William T. Mallard
  • 1,562
  • 2
  • 25
  • 33
  • This problem remains with AS Android Studio 4.1.2 Build #AI-201.8743.12.41.7042882, built on December 19, 2020 – Hong Mar 17 '21 at 13:24
  • This problem seems fixed with Android Studio 4.2 Build #AI-202.7660.26.42.7322048, built on April 29, 2021 – John Pang May 08 '21 at 16:14

1 Answers1

10

Amusingly, I'm able to work around this by suppressing the suppression warning like so:

    @SuppressWarnings({"unused", "RedundantSuppression"})
William T. Mallard
  • 1,562
  • 2
  • 25
  • 33
  • I'm downvoting that to punish Android Studio, not you. This bug creates an infinite loop of suppression, suppressing the suppression, etc... – Phlip Feb 09 '21 at 03:49
  • 4
    @Philip, that's not how the voting works. I think you're supposed to downvote only if there's a problem with the answer, not whether or not you like what the answer is about, no? – William T. Mallard Feb 11 '21 at 15:37
  • 1
    This really is amusing, thanks for the solution, and I'm pretty sure this should be reported as a bug against either AS or the SDK. – Violet Giraffe Feb 25 '21 at 17:39
  • 1
    There is hope: https://youtrack.jetbrains.com/issue/IDEA-249790, indicating it's fixed in IntelliJ IDEA 20.2.3 while current Android Studio (4.1.3) is based on v. 20.1. Nice workaround. :) –  Apr 11 '21 at 08:02
  • 1
    This problem seems fixed with Android Studio 4.2 Build #AI-202.7660.26.42.7322048, built on April 29, 2021 – John Pang May 08 '21 at 16:15
  • 1
    Nice workaround. Bug still present in 2023 (Android Studio Electric Eel | 2022.1.1). – Luis A. Florit Jan 14 '23 at 15:48