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

Return type of suspend function not considered for public API #1324

Open
eygraber opened this issue Nov 26, 2024 · 3 comments
Open

Return type of suspend function not considered for public API #1324

eygraber opened this issue Nov 26, 2024 · 3 comments
Labels
bug Something isn't working toolchain:kotlin
Milestone

Comments

@eygraber
Copy link

eygraber commented Nov 26, 2024

Plugin version
2.5.0

Gradle version
8.11.1

JDK version
22

Kotlin and Kotlin Gradle Plugin (KGP) version
2.0.21

Android Gradle Plugin (AGP) version
8.7.2

Describe the bug
I have 3 modules:

module A

interface MyResult

module B (api(projects.A))

interface Foo {
  suspend fun bar(): MyResult
}

module C (implementation(projects.B), implementation(projects.A))

class Baz(
  private val foo: Foo,
) {
  suspend fun bing() {
    foo.bar()
  }
}

Running buildHealth fails with:

> Advice for :B
  Existing dependencies which should be modified to be as indicated:
    implementation(projects.A) (was api)
  
  Advice for :C
  Unused dependencies which should be removed:
    implementation(projects.A)

Running :B:reason --id :A:

------------------------------------------------------------
You asked about the dependency ':A'.
You have been advised to change this dependency to 'implementation' from 'api'.
------------------------------------------------------------

Source: devDebug, main
----------------------
* Imports 1 class: MyResult (implies implementation).

Running :B:reason --id :A:

------------------------------------------------------------
You asked about the dependency ':A'.
You have been advised to remove this dependency from 'implementation'.
------------------------------------------------------------

Source: devDebug, main
----------------------
(no usages)

If I follow the advice then compiling C fails:

e: Baz.kt:20:52 Cannot access class 'MyResult'. Check your module classpath for missing or conflicting dependencies.
@eygraber eygraber changed the title Return type not considered for public API Return type of suspend function not considered for public API Nov 27, 2024
@eygraber
Copy link
Author

repro.zip

Running ./gradlew buildHealth on the repro above fails only when foo is a suspending function in services/foo/public/src/main/kotlin/template/services/foo/Foo.kt.

@autonomousapps
Copy link
Owner

Thanks for the report. I note the description of the issue (in the text) doesn't include any suspend functions. Does the repro contain suspend functions? (I haven't downloaded it yet.) If so, could you update the description?

@autonomousapps autonomousapps added bug Something isn't working toolchain:kotlin labels Dec 2, 2024
@autonomousapps autonomousapps added this to the next milestone Dec 2, 2024
@eygraber
Copy link
Author

eygraber commented Dec 2, 2024

Updated. The repro project looks pretty different though, the description here was originally derived from that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working toolchain:kotlin
Projects
None yet
Development

No branches or pull requests

2 participants