https://kotlinlang.org logo
#arrow-meta
Title
# arrow-meta
t

than_

06/29/2021, 12:14 PM
Hi, when trying to define my own refined types I'm getting an
java.lang.IllegalArgumentException: object is not an instance of declaring class : package.PositiveInt2.Companion.invoke
This happens just by defining new refined type. I tried to copy
PositiveInt
and just change the name
Copy code
class PositiveInt2 private constructor(val value: Int) {
    companion object : Refined<Int, PositiveInt2>(::PositiveInt2, {
        ensure((it > 0) to "$it should be > 0")
    })
}
is it a bug in a
io.arrow-kt:arrow-refined-types-gradle-plugin:1.5.0-SNAPSHOT
or am I missing something?
r

raulraja

06/29/2021, 12:25 PM
Hi @than_ are you using any other compiler plugins in that project?
t

than_

06/29/2021, 12:26 PM
kotlinx.serialization
some others as well. it happens in multiple projects
Copy code
plugins {
    kotlin("multiplatform") version "1.5.0"
    kotlin("plugin.serialization") version "1.5.0"
    kotlin("kapt") version "1.5.0"
    id("com.github.johnrengelman.shadow") version "6.1.0"
    id("org.jlleitschuh.gradle.ktlint") version "10.0.0"
    application
}
and
Copy code
plugins {
    id("com.android.application")
    id("kotlin-android")
    id("kotlin-kapt")
    id("org.jetbrains.kotlin.plugin.serialization") version "1.5.0"
    id("kotlin-parcelize")
}
r

raulraja

06/29/2021, 12:32 PM
I have not seen that error before. I suppose one of those other plugins is mangling the class somehow. I would try with a regular value class just in case:
Copy code
@JvmInline
value class PositiveInt private constructor(val value: Int) {
  companion object : Refined<Int, PositiveInt>(::PositiveInt, {
    ensure((it > 0) to "$it should be > 0")
  })
}
If that doesn’t work please feel free to create an issue with a minimal repro project and we can take a look at it before the next snapshot release. This plugin is not stable yet.
t

than_

06/29/2021, 1:54 PM
Thanks for your time. I understand all things meta related are not stable yet.
For anyone interested: Bug report here https://github.com/arrow-kt/arrow-meta/issues/825
r

raulraja

06/29/2021, 4:17 PM
thanks @than_ 🙂
2 Views