How to avoid knownDirectSubclasses errors in Scala 2.12.4+?


#1

This is the error I get (stripped down project here):

[IJ]> ~web-server/re-start
[info] Compiling 4 Scala sources to /home/brandon/workspace/ProjectGists/CCRS_knownDirectSubclasses/web-server/target/scala-2.12/classes...
[error] knownDirectSubclasses of FileCommand observed before subclass ExecFile registered
[error] one error found
[error] (web-server/compile:compileIncremental) Compilation failed
[error] Total time: 1 s, completed Apr 26, 2018 3:00:49 PM

Workaround suggestions would also be much appreciated. Two non-workaround ways of getting the error to go away:

  1. Delete ExecFile
  2. Delete AutowireServer’s dispatch method

I also posted this at https://github.com/scala/bug/issues/10330 due to being possibly related, but it may be a different issue. However, I think it is definitely related, as other posts seem to describe issues with autogenerated classes being the issue, and something related to boopickle is problem happening here.


#2

I have a project that contains a file in the top level package called aaaCompileFirst.scala. It contains all the Enumeratum enums. It’s the only workaround I’ve found to avoid this. It is definitely not fixed in 2.12.4.


#3

Hmm, that’s good to know. I guess I can’t use that as a workaround though, or not directly, since presumably part of the problem is some classes are being generated from macros that I’m using, which end up causing the problem


#4

I can’t pretend to follow the partial fix Miles implemented but Enumeratum is full of macros and if the compiler doesn’t encounter these right at the beginning I get the issue. It’s probably worth a try.