You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
objectdemo {
traitReader[A]
givenReader[Int] with {}
inlinedefsummonReader[T<:Tuple]:List[Reader[_]] =inline compiletime.erasedValue[T] match {
case_: EmptyTuple=>Nilcase_: (t *: ts) => compiletime.summonInline[Reader[t]] :: summonReader[ts]
}
classCombinedReader[A](
m: deriving.Mirror.ProductOf[A],
childReaders: List[Reader[_]]
) extendsReader[A]
inlinegiven [A<:Tuple](usingm: deriving.Mirror.ProductOf[A]):Reader[A] = {
newCombinedReader(m, summonReader[m.MirroredElemTypes])
}
}
@main defrun() = {
// OK//summon[demo.Reader[(Int, Int, Int)]]// Exception in thread "main" java.lang.ClassCastException: class main$package$$anon$2 cannot be cast to class scala.deriving.Mirror$Product (main$package$$anon$2 and scala.deriving.Mirror$Product are in unnamed module of loader 'app')// at main$package$.run(main.scala:25)// at run.main(main.scala:23)
summon[demo.Reader[(Int, (Int, Int))]]
}
Output
The program compiles, but encounters a ClassCastException at runtime, as shown in the comment above.
Expectation
There should be no exception.
Notes
The class cast exception only happens if the mirror is captured and there is a nested summoning. If, for example, CombinedReader would not use take m or childReader arguments, the program works as expected.
The text was updated successfully, but these errors were encountered:
Mirror support runs in PostTyper to add new members to mirrors generated
during Typer. But some anonymous mirrors are generated during inlining.
We need to add the missing methods for them as well.
Fixesscala#11542Fixesscala#11961Fixesscala#12052
Mirror support runs in PostTyper to add new members to mirrors generated
during Typer. But some anonymous mirrors are generated during inlining.
We need to add the missing methods for them as well.
Fixesscala#11542Fixesscala#11961Fixesscala#12052
michelou
pushed a commit
to michelou/scala3
that referenced
this issue
Apr 14, 2021
Mirror support runs in PostTyper to add new members to mirrors generated
during Typer. But some anonymous mirrors are generated during inlining.
We need to add the missing methods for them as well.
Fixesscala#11542Fixesscala#11961Fixesscala#12052
Compiler version
3.0.0-RC1
Minimized code
Output
The program compiles, but encounters a ClassCastException at runtime, as shown in the comment above.
Expectation
There should be no exception.
Notes
The class cast exception only happens if the mirror is captured and there is a nested summoning. If, for example,
CombinedReader
would not use takem
orchildReader
arguments, the program works as expected.The text was updated successfully, but these errors were encountered: