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

@optics generates bad code for data class with generic named 'S' #3399

Open
ajrouvoet opened this issue Mar 22, 2024 · 0 comments
Open

@optics generates bad code for data class with generic named 'S' #3399

ajrouvoet opened this issue Mar 22, 2024 · 0 comments

Comments

@ajrouvoet
Copy link

With arrow 1.2.3 on Kotlin 1.9.23 and ksp 1.0.19 the following declaration causes bad code to be generated:

@optics
data class Box<S>(val s: S) {
    companion object
}

producing:

public inline fun <S,S> arrow.optics.Iso<S, Box<S>>.s(): arrow.optics.Lens<S, S> = this + Box.s()
public inline fun <S,S> arrow.optics.Lens<S, Box<S>>.s(): arrow.optics.Lens<S, S> = this + Box.s()
public inline fun <S,S> arrow.optics.Optional<S, Box<S>>.s(): arrow.optics.Optional<S, S> = this + Box.s()
public inline fun <S,S> arrow.optics.Prism<S, Box<S>>.s(): arrow.optics.Optional<S, S> = this + Box.s()
public inline fun <S,S> arrow.optics.Getter<S, Box<S>>.s(): arrow.optics.Getter<S, S> = this + Box.s()
public inline fun <S,S> arrow.optics.Setter<S, Box<S>>.s(): arrow.optics.Setter<S, S> = this + Box.s()
public inline fun <S,S> arrow.optics.Traversal<S, Box<S>>.s(): arrow.optics.Traversal<S, S> = this + Box.s()
public inline fun <S,S> arrow.optics.Fold<S, Box<S>>.s(): arrow.optics.Fold<S, S> = this + Box.s()
public inline fun <S,S> arrow.optics.Every<S, Box<S>>.s(): arrow.optics.Every<S, S> = this + Box.s()

which naturally fails to compile due to the duplicate declarations of the type variable S.

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

1 participant