-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Cannot Use a Mirror Summoned via summonExpr #7853
Comments
It looks like it is already fixed on master |
Okay, thanks. Where can I grab the overnight build and try it out? |
Wait a minute, are you sure this is working I'm running [error] java.lang.RuntimeException: mirror was an invalid value: <function2>
[error] at derivation.Test$$anon$1.encode(SummonTest.scala:12)
[error] at derivation.Test$$anon$1.encode(SummonTest.scala:12)
[error] at derivation.Test$.main(SummonTest.scala:12)
[error] at derivation.Test.main(SummonTest.scala)
[error] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] at java.lang.reflect.Method.invoke(Method.java:498)
[error] Nonzero exit code: 1 |
That seems to be another error. Is the code bug free? Is the compiler generating wrong code? Maybe open another issue. |
I used the same code as found in @liufengyun's posted code here. |
This line should probably be a compile time error. |
Oh, it cannot fin the mirror and then defaults to any implicit it finds. That is where the function2 comes from. Maybe just remove that case. |
That causes: [error] | cannot reduce inline match with
[error] | scrutinee: {
[error] | ev
[error] | } : (ev :
[error] | scala.deriving.Mirror{
[error] | MirroredType = T; MirroredMonoType = T; MirroredElemTypes <: Tuple
[error] | }
[error] | )
[error] | patterns : case m @ _:deriving.Mirror.SumOf[T]
[error] | case m @ _:deriving.Mirror.ProductOf[T]
[error] | This location contains code that was inlined from JsonEncoder.scala:28
[error] -- Error: /home/alexander/git/dotty/mirror_test/src/main/scala/org/deusaquilus/Test.scala:11:57
[error] 11 | println(SummonJsonEncoderTest.encodeAndMessAroundType(stuff) ) I'll post the exact code to a repo in a second. |
Here's the exact code: |
Please have a look at #7974 |
minimized code
Let's say I have a simple json encoder, for the sake of example it can be any kind of encoder that uses
derived
.Now, inside of a macro, I want to be able to take an abitrary type, summon the mirror for it, and then use the encoder.
Then let's say I use this in some "client-facing" code:
expectation
The above code should work. Instead, it causes the error:
The text was updated successfully, but these errors were encountered: