Summary
Deriving Eq (or Order) for a parameterless enum makes the generated code in EqEnumRule / OrderEnumRule emit a compiler warning:
the type test for E.A cannot be checked at runtime because it refers to an abstract type member or type parameter
Because the warning originates from kindlings' own generated code, users can't fix it at the call site, and any project compiling with -Werror (fatal warnings) fails to build.
Minimal reproduction (scala-cli)
//> using scala 3.8.4
//> using dep com.kubuszok::kindlings-cats-derivation:0.3.1
//> using option -Werror
import cats.Eq
import hearth.kindlings.catsderivation.extensions.*
enum E derives Eq {
case A, B
}
Compiling yields:
[error] .../hearth/kindlings/catsderivation/internal/compiletime/rules/EqEnumRule.scala:1:1
[error] the type test for E.A cannot be checked at runtime because it refers to an abstract type member or type parameter
Without -Werror it is a [warn] (still emitted on every compile).
Scope
- Reproduces with
Eq (EqEnumRule) and Order (OrderEnumRule) — the generated per-case type test in the enum comparison rules seems to be the common cause.
- Happens for a minimal 2-case parameterless enum.
Comparison with kittens
kittens (org.typelevel::kittens:3.5.0) derives Eq for the same enum on the same Scala version with no warning:
//> using scala 3.8.4
//> using dep org.typelevel::kittens:3.5.0
import cats.Eq
import cats.derived.*
enum E derives Eq { case A, B } // compiles clean, no warnings
Environment
- kindlings-cats-derivation:
0.3.1
- Scala:
3.8.4
- scala-cli:
1.15.0, JVM 21
Expected
Generated enum Eq/Order instances should not emit unchecked-type-test warnings (e.g. match on the enum ordinal/==, or generate type tests the compiler can check), so that derivation is clean under -Werror.
Summary
Deriving
Eq(orOrder) for a parameterlessenummakes the generated code inEqEnumRule/OrderEnumRuleemit a compiler warning:Because the warning originates from kindlings' own generated code, users can't fix it at the call site, and any project compiling with
-Werror(fatal warnings) fails to build.Minimal reproduction (scala-cli)
Compiling yields:
Without
-Werrorit is a[warn](still emitted on every compile).Scope
Eq(EqEnumRule) andOrder(OrderEnumRule) — the generated per-case type test in the enum comparison rules seems to be the common cause.Comparison with kittens
kittens (
org.typelevel::kittens:3.5.0) derivesEqfor the same enum on the same Scala version with no warning:Environment
0.3.13.8.41.15.0, JVM 21Expected
Generated enum
Eq/Orderinstances should not emit unchecked-type-test warnings (e.g. match on the enum ordinal/==, or generate type tests the compiler can check), so that derivation is clean under-Werror.