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

Allow empty constructur call in expected class declaration #2425

Closed
vanniktech opened this issue Dec 10, 2023 · 4 comments · Fixed by #2431
Closed

Allow empty constructur call in expected class declaration #2425

vanniktech opened this issue Dec 10, 2023 · 4 comments · Fixed by #2431
Milestone

Comments

@vanniktech
Copy link
Contributor

Using 1.0.1 the following gets flagged:

@OptIn(ExperimentalMultiplatform::class)
@OptionalExpectation
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.BINARY)
expect annotation class Parcelize()

@OptIn(ExperimentalMultiplatform::class)
@OptionalExpectation
@Target(AnnotationTarget.PROPERTY)
@Retention(AnnotationRetention.SOURCE)
expect annotation class IgnoredOnParcel()

@OptIn(ExperimentalMultiplatform::class)
@OptionalExpectation
@Retention(AnnotationRetention.SOURCE)
@Repeatable
@Target(AnnotationTarget.CLASS, AnnotationTarget.PROPERTY)
expect annotation class TypeParceler<T, P : Parceler<in T>>()

with:

commonParcelableApi.kt:11:34: No parenthesis expected (standard:class-signature)
commonParcelableApi.kt:17:40: No parenthesis expected (standard:class-signature)
commonParcelableApi.kt:24:60: No parenthesis expected (standard:class-signature)

And the formatting removes the () however this causes a compilation error: e: Color.kt:35:2 This class does not have a constructor

You can use vanniktech/ui#100 to repro

@paul-dingemans
Copy link
Collaborator

The problem seems to be caused by the expect. I am unfamiliar with it. I have found https://kotlinlang.org/api/latest/kotlin.test/kotlin.test/expect.html. Can you give more information why and how it is used?

@paul-dingemans paul-dingemans added this to the 1.1 milestone Dec 10, 2023
@TWiStErRob
Copy link
Contributor

It's not kotlin-test expect, but KMM's expect and actual.

https://kotlinlang.org/docs/multiplatform-expect-actual.html

TL;DR roughly:

  • expect is like an interface declaration of API to be compiled against in common code
  • actual is the implementation to be linked at compile time of platform-specific code

@paul-dingemans
Copy link
Collaborator

It's not kotlin-test expect, but KMM's expect and actual.

https://kotlinlang.org/docs/multiplatform-expect-actual.html

TL;DR roughly:

  • expect is like an interface declaration of API to be compiled against in common code
  • actual is the implementation to be linked at compile time of platform-specific code

Tnx. That is clarifying. If you stuck for now, you can either disable the class-signature rule entirely, or with a file annotation just only for the file in which the expect declaration is used.

@paul-dingemans paul-dingemans changed the title False positive class-signature Allow empty constructur call in expected class declaration Dec 11, 2023
@vanniktech
Copy link
Contributor Author

Yup I already disabled the rule entirely. Luckily that one had no dependencies that I needed to disable as well, so all good!

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

Successfully merging a pull request may close this issue.

3 participants