Skip to content
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

EffectsKt.LaunchedEffect is deprecated; but only one override deprecated causes Lint warning #310

Closed
kozaxinan opened this issue Sep 20, 2024 · 5 comments

Comments

@kozaxinan
Copy link

LaunchedEffect and DisposableEffect without key parameters are deprecated. Eventhough we dont use any of those deprecated functions, Deprecated lint check fails.

@ZacSweers
Copy link
Collaborator

@kozaxinan can you please add a bit more detail or a reproducible sample

@kozaxinan
Copy link
Author

kozaxinan commented Sep 26, 2024

Hi, you are right. Original description doesn't contain much details.

With @ZeeshanShabbir, we created a project to reproduce. https://github.com/kozaxinan/lint-investigation

run ./gradlew :app:lintDebug

Details

Kotlin 2.0.20
Compose 2024.09.02
AGP 8.6.1
Slack lint 0.7.4

here is the lint result

Screenshot 2024-09-26 at 16 48 04

@kozaxinan
Copy link
Author

I also tried to write an unit test but tests are working as expected.


  @Test
  fun `kotlin-sourced non-deprecated overridden method use has no warning in kotlin`() {
    lint()
      .files(
        DEPRECATED_METHOD_OVERRIDE_KOTLIN,
        kotlin(
            """
                  package slack.test

                  import slack.test.thisIsDeprecated

                  class TestClass {

                    public fun doStuff() {
                      thisIsDeprecated() {}

                      thisIsDeprecated("This is NOT deprecated overridden version.") {}
                    }
                  }
                """
          )
          .indented(),
      )
      .issues(DeprecatedAnnotationDetector.ISSUE_DEPRECATED_CALL)
      .run()
      .expect(
        """
          src/slack/test/TestClass.kt:8: Warning: slack.test.TestKt.thisIsDeprecated is deprecated; consider using an alternative. [DeprecatedCall]
              thisIsDeprecated() {}
              ~~~~~~~~~~~~~~~~~~~~~
          0 errors, 1 warnings
        """
          .trimIndent()
      )
  }

  private val DEPRECATED_METHOD_OVERRIDE_KOTLIN =
    kotlin(
      """
          package slack.test

          import kotlin.Deprecated
          import kotlin.DeprecationLevel

          // This deprecated-error function shadows the varargs overload so that the varargs version
          // is not used without key parameters.
          @Deprecated("", level = DeprecationLevel.ERROR)
          public fun thisIsDeprecated(
            block: suspend () -> Unit
          ) = Unit

          public fun thisIsDeprecated(param: Any?, block: suspend () -> Unit) {}
          public fun thisIsDeprecated(param: Any?, param1: Any?, block: suspend () -> Unit) {}
          public fun thisIsDeprecated(vararg params: Any?, block: suspend () -> Unit) {}
        """
    )

@kozaxinan kozaxinan changed the title EffectsKt.LaunchedEffect is deprecated; but only some overrides deprecated EffectsKt.LaunchedEffect is deprecated; but only one override deprecated causes Lint warning Sep 27, 2024
@ZacSweers
Copy link
Collaborator

Deduping into #268. Can you try with Lint 8.7.0+ to see if that resolves anything?

@ZacSweers ZacSweers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 2, 2024
@kozaxinan
Copy link
Author

8.7.0 didnt change the result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants