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

Generated code for Show Typeclass does not escape Kotlin keywords. #1408

Closed
ragunathjawahar opened this issue Apr 15, 2019 · 2 comments
Closed

Comments

@ragunathjawahar
Copy link

Source

package `in`.demo.arrow.playground

import arrow.extension
import arrow.typeclasses.Show

data class Temperature(
  val value: Double
)

inline class Celsius(val t: Temperature)

@extension interface CelsiusShow : Show<Celsius> {
  override fun Celsius.show(): String = (t.value - 273.15).to2DecimalPlaces()
}

Generated Code

package `in`.demo.arrow.playground.celsius.show

import `in`.demo.arrow.playground.Celsius
import `in`.demo.arrow.playground.Celsius.Companion
import `in`.demo.arrow.playground.CelsiusShow
import kotlin.String
import kotlin.Suppress
import kotlin.jvm.JvmName

@JvmName("show")
@Suppress(
        "UNCHECKED_CAST",
        "USELESS_CAST",
        "EXTENSION_SHADOWED_BY_MEMBER",
        "UNUSED_PARAMETER"
)
fun Celsius.show(): String = in.demo.arrow.playground.Celsius.show().run { // <-- BUG: Generated code does not escape Kotlin keywords (in)
  this@show.show() as kotlin.String
}

fun Companion.show(): CelsiusShow = object : `in`.demo.arrow.playground.CelsiusShow {  }
@ragunathjawahar
Copy link
Author

@raulraja if I were to send a PR for this issue, is it okay to add a new dependency for testing? I see the project already has Google's Compile Testing. However, there is a new library for Kotlin as well.

https://github.com/permissions-dispatcher/kompile-testing

@raulraja
Copy link
Member

@ragunathjawahar sorry this fell through the cracks and I never got to reply to you. We are no longer supporting this type of type class in Arrow in the latest versions. Again my apologies for the years late reply. Closing this now 🙏

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