These are chat archives for typelevel/scala

7th
Dec 2016
jeremyrsmith
@jeremyrsmith
Dec 07 2016 03:56

for SI-7046, can't we redo compilation units that depended on knownDirectSubclasses when we know they didn't see all of them, rather than erroring? Trying to use i.e. circe derivation for stuff like

sealed trait Foo
object Foo {
  case class A(...) extends Foo
  case class B(...) extends Foo
}

in order to keep the leaves out of the namespace causes freakouts but seems like a pretty common want

Miles Sabin
@milessabin
Dec 07 2016 08:36
That should be fine with TLS 2.11.8 or LBS 2.12.1 ... are you seeing a problem with either of those?
Miles Sabin
@milessabin
Dec 07 2016 14:46
@andyscott where is the alternative predef PR at now?
I want to make a TLS 2.12.1 release before the break and I'd really like to get it in if possible.
jeremyrsmith
@jeremyrsmith
Dec 07 2016 15:54

@milessabin when I have code like this

sealed trait Foo
object Foo {
  case class A(...) extends Foo
  case class B(...) extends Foo
  implicit val decoder = deriveDecoder[Foo]
}

for circe's semiauto, I get

[error] knownDirectSubclasses of Foo observed before subclass A registered
[error] knownDirectSubclasses of Foo observed before subclass B registered

with TLS 2.11.8; not sure what else is at play that might cause it

Miles Sabin
@milessabin
Dec 07 2016 16:19
Interesting.
You'll have to move the implicit val somewhere else I'm afraid.
Ahh ... or maybe give it an explicit result type.
jeremyrsmith
@jeremyrsmith
Dec 07 2016 16:28
I also get a crazy macro error that doesn't happen in vanilla Scala 2.11.8
symbol value inst$macro$73#136896 does not exist in Foo$$anonFun$6.apply, which contains locals .
Miles Sabin
@milessabin
Dec 07 2016 16:32
Is your ADT recursive?
jeremyrsmith
@jeremyrsmith
Dec 07 2016 16:34
parts of it are, but not the part it's complaining about
adding type annotations to the implicits does help in both vanilla and TLS, incidentally
Miles Sabin
@milessabin
Dec 07 2016 16:36
Can you work with @travisbrown to try and produce a minimal reproduction?
jeremyrsmith
@jeremyrsmith
Dec 07 2016 16:36
yep I'll see if i can minimize it
Miles Sabin
@milessabin
Dec 07 2016 16:37
I'm mean more minimal that that ... there are lots of moving parts under Circe's hood.
jeremyrsmith
@jeremyrsmith
Dec 07 2016 16:37
annotating all the implicit vals seems to have made that error go away though
so maybe the lesson is just always annotate your implicits
Miles Sabin
@milessabin
Dec 07 2016 16:38
I'm not sure if that's good advice though ... it could be that those vals are being null initialized now.
I'm not sure what deriveDecoder is doing under the hood.
jeremyrsmith
@jeremyrsmith
Dec 07 2016 16:39
after annotating all of them I can also put ADT leaves in the root's companion like I was trying to do before, in both TLS and vanilla
Miles Sabin
@milessabin
Dec 07 2016 16:41
I appreciate that that's a fix for your immediate problem, but it doesn't really help me diagnose it.
jeremyrsmith
@jeremyrsmith
Dec 07 2016 16:42
yes, I'll see if I can reproduce it in a minimal example
Miles Sabin
@milessabin
Dec 07 2016 17:06
@jeremyrsmith I've got a minimal reproduction. I believe that the "observed before registered" errors are correct, so this is saving you from grief later on.