Alexander Ioffe
08/22/2025, 3:39 PMabstract class MySpec(
val variousStuff: VariousStuff,
body: MySpec.() -> Unit
): FreeSpec(body as Function1<FreeSpec, Unit>) { ... }
It works just fine for JVM but when I try doing a native (e.g. LinuxX64) it produces an invalid entry in kotest.kt
that looks like this:
SpecRef.Function ({ `Test1`() }, `Test1`::class, "my.stuff.Test1"),
SpecRef.Function ({ `Test2`() }, `Test2`::class, "my.stuff.Test2"),
SpecRef.Function ({ `MySpec`() }, `MySpec`::class, "my.stuff.MySpec"),
SpecRef.Function ({ `Test3`() }, `Test3`::class, "my.stuff.Test3"),
SpecRef.Function ({ `Test4`() }, `Test4`::class, "my.stuff.Test4"),
I worked around it by making MySpec
a regular (albeit open) class and adding a no-args constructor but it seems like a hack. Maybe the Kotest KSP could be modified to check if the class is abstract and then not add it to this list? I think you could do something like:
(type:KSType).declaration.modifiers.contains(Modifier.ABSTRACT)