ClassCastException when summoning Mirror for hierarchical sum compiled by 3.0.x
See original GitHub issueCompiler version
3.1.0
Minimized code
compile with Scala 3.0.2 to out
dir
sealed trait Top
object Top // companion is necessary
case class Middle() extends Top with Bottom
sealed trait Bottom extends Top
compile with Scala 3.1.0 and with out
on classpath
val m = summon[deriving.Mirror.SumOf[Top]]
Output
runtime error:
java.lang.ClassCastException: Top$ cannot be cast to scala.deriving.Mirror$Sum
... 28 elided
This happens because Top
is an eligible sum, and it has a companion object (which if compiled by Scala 3.1.0 would extend deriving.Mirror.Sum
), so the companion object is used as the mirror and is cast to Sum
.
Expectation
prevent summoning mirrors for hierarchical sums with companion objects compiled before 3.1.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Scala 3: How do you extract the names of elements from a ...
I think there is a bug, since I have been able to extract element labels from Product mirrors, but not Sum s. It...
Read more >Advisory Board 2021 Q4 Report - Scala Center
Mirror.SumOf[T]`, where `T` is a hierarchical sum type compiled by Scala 3.0.x, could cause a ClassCastException). To fix this.
Read more >java array in methods Code Example
String intArrayString = Arrays.toString(intArray);. 3. 4. // print directly will print reference value. 5. System.out.println(intArray);.
Read more >mondrian-users Mailing List for Mondrian (Page 2)
hello, I have downloaded the mondrian 2.3.2 source code and compiled in my pc. ... This should mirror an SQL report: SELECT SUM(oi.unit_price...
Read more >https://huggingface.co/jeniya/BERTOverflow/commit/...
+/ +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +: +; +< += +> +? +@ +A +B +C +D +E...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Currently, the community build rebuilds all transitive dependencies from sources, this is a great showcase of why we may want to also have a version of the community build which keeps the binary dependencies.
This sounds very reasonable to me.
Summarising a Slack discussion: @dwijnand and @julienrf also asked if we can check if the companion is a subtype of
Mirror.Sum
, I said this is not possible with code compiled from source, as mirror synthesis happens too early in the compiler currently, so @dwijnand suggested that if we can check if a type is a compiled dependency, then check that its companion extendsMirror.Sum
, else keep the current behavior.this change can be implemented in
SymUtils.useCompanionAsMirror