question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Circe Enumeratum knownDirectSubclasses compile time error

See original GitHub issue

Error during compilation of a CirceEnum: knownDirectSubclasses observed before subclass registered

Using:

  • Scala - 2.12.1
  • enumeratum - 1.5.3
  • enumeratum-circe - 1.5.3

Enumeratum ADT looks like:

import enumeratum._
sealed trait Role extends EnumEntry
case object Role extends CirceEnum[Role] with Enum[Role] {
  case object Service extends Role
  case object User extends Role
  val values = findValues
}

For this case, two errors are produced:

[error] knownDirectSubclasses of Role observed before subclass Service registered
[error] knownDirectSubclasses of Role observed before subclass User registered

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
joan38commented, May 22, 2017

Rename your Enum trait to AWhatwver. It just needs to start with a letter high enough in the alphabetical order. What a joke.

Using 2.12.2 See: https://github.com/circe/circe/issues/639

3reactions
zergincommented, Mar 21, 2017

For other poor souls trying to get it to work. For me the fix was to force imports order:

import TextType._
import io.circe.generic.auto._
import de.heikoseeberger.akkahttpcirce.CirceSupport

where TextType extends EnumEntry. It does not matter weather enumerated types are used or not in the class (for me they’re not). The only thing that triggered working code path was to have all enumerated types imported before io.circe.generic.auto._.

This seems to work for both generic akka-http application and unit tests with isolated Circe encoding/decoding.

Read more comments on GitHub >

github_iconTop Results From Across the Web

lloydmeta/enumeratum - Gitter
hi enumeratum, I'm struggling with issue#90 - I can't seem to get it to stable state. while I can get it to compile...
Read more >
Unable to resolve compile time error in circe custom decoder
I am trying to write a custom encoder and decoder in Circe for an Object like case class User(id: Long, name: String). So...
Read more >
Adding Enumeratum to the Scala Platform
ValueEnum was written to solve the problem of not having compile-time uniqueness checks on Enum values and to be able to deserialise ...
Read more >
Troubleshooting - sbt - Triplequote Hydra
Using Enumeratum: knownDirectSubclasses of ... observed before subclass .. registered¶. Enumeratum, especially when combined with Circe may exhibit a known bug ...
Read more >
Fix the top 10 most common compile time errors in Java
Compile time errors in Java can be confusing and frustrating. Be prepared with this list of the 10 most common Java compile errors...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found