-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compilation with -Ypartial-unification flag fails #109
Comments
Ping @cornerman |
Interesting report! Spontaneously I have no idea why this happens and I am not sure whether we can do anything about this. The shapeless module pretty much only provides
I am not an expert here either, but the examples might really show what
|
@cornerman thank you for the attention. I looked into the implementation of Shapeless' Perhaps, you can help me convert this test case into one that is using vanilla Shapeless, stripping down BooPickle? I would then be able to post an issue at Shapeless repo, the creator of which, is also the author of |
@aSapien Maybe let us just start with what we want to achieve in the Let us say, we have a case class Foo(i: Int, s: String)
val aux = Generic[Foo] // shapeless.Generic[Foo]{type Repr = Int :: String :: shapeless.HNil}
aux.to(Foo(1, "hallo")) == 1 :: "hallo" :: HNil
aux.from(2 :: "nope" :: HNil) == Foo(2, "nope") So with this Now, we further want to be able to pickle trait hierarchies, which is why we need to support sealed trait Vehicle
case class Car() extends Vehicle
case class Motorcycle() extends Vehicle
val aux = Generic[Vehicle] // shapeless.Generic[Vehicle]{type Repr = Car :+: Motorcycle :+: shapeless.CNil}
aux.from(Inl(Car())) == Car()
aux.to(Car()) == Inl(Car()) I hope this helps a bit in understanding. I am testing right now in a project of mine and now see similar errors when using boopickle-shapeless and partial unification in combination. I sadly do not have a good idea how to isolate the issue right now :/ Maybe it has something to do with implicit resolution. |
@cornerman that's a great explanation. Thanks! Hope you have some progress as well. |
Enabling The trick here is to juggle with implicit priorities until it works. If you don't have too many instances then you should be able to figure this out by trial and error. |
@milessabin is there a way to effectively inspect the implicit scope? Define priorities? I think the problem I'm facing here is that the expected implicit should be generated by a Shapeless macro, but isn't because |
Inspecting the logs output for macros materialization, with and without The succeeding version (green) is materializing the following macro, while the failing (red) is attempting (and failing) to materialize a different one: +Warning:scalac: performing macro expansion shapeless.this.Generic.materialize[example.TestCase.Parametrized[_], R] at source-.../TestCase.scala,line-12,offset=265
-Warning:scalac: performing macro expansion shapeless.this.Generic.materialize[Seq[String], R] at source-.../TestCase.scala,line-12,offset=265 Notice the same line and offset: line-12,offset=265 |
tl;dr
Compilation fails with boopickle-shapeless and
-Ypartial-unification
. Test case repo hereFull story
Recently I needed to enable
-Ypartial-unification
in a codebase I'm working on. To my surprise, at a specific part of the codebase - compilation failed, which forced me to revert the change.I invested an effort to investigate and resolve the issue, but to no avail. However, I did manage to isolate the issue for the purpose of seeking help online.
I created a repo with a small test case which fails to compile with
-Ypartial-unification
. Link hereThis is the code for the test case:
Compilation fails with the following error
I decided to add compiler debug flags, one of the compiler flags (namely
-Ymacro-debug-lite
) revealed that a missing implicit was expected to be materialized by a macro, but was not. Finding the reason currently appears to be beyond my skills and expertise.Comparing the logs of the failing and succeeding compilations output (with
-Ymacro-debug-lite
flag) I can see that the failing version is missing the following macro expansion:It's important to note that making minor changes to the code results in a successful compilation. Some examples are:
Any of the above changes somehow facilitates a successful compilation.
I appreciate any help that can help me understand the problem and cause since it blocks me from introducing
-Ypartial-unification
because I fear other issues may arise, which I'll be unable to understand and resolve.Thanks,
Dima
The text was updated successfully, but these errors were encountered: