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
This is a version of the test tests/run/poly-kinded-derives.scala where all type parameters are made explicit. The critical change is in the the line marked // <<<<
importscala.deriving._objectTestextendsApp {
{
traitShow[T]
objectShow {
givenShow[Int] {}
given [T](usingst: Show[T]) as Show[Tuple1[T]]
givent2[T, U](usingst: Show[T], su: Show[U]) as Show[(T, U)]
givent3 [T, U, V](usingst: Show[T], su: Show[U], sv: Show[V]) as Show[(T, U, V)]
defderived[T](usingm: Mirror.Of[T], r: Show[m.MirroredElemTypes]):Show[T] =newShow[T] {}
}
caseclassMono(i: Int) derivesShowcaseclassPoly[A](a: A) derivesShow//case class Poly11[F[_]](fi: F[Int]) derives ShowcaseclassPoly2[A, B](a: A, b: B) derivesShowcaseclassPoly3[A, B, C](a: A, b: B, c: C) derivesShow
}
{
traitFunctor[F[_]]
objectFunctor {
given [C] as Functor[[T] =>>C] {}
givenFunctor[[T] =>>Tuple1[T]] {}
givent2 [T] as Functor[[U] =>> (T, U)] {}
givent3 [T, U] as Functor[[V] =>> (T, U, V)] {}
defderived[F[_]](usingm: Mirror { typeMirroredType[X] =F[X] ; typeMirroredElemTypes[_] }, r: Functor[m.MirroredElemTypes]):Functor[F] =newFunctor[F] {}
}
caseclassMono(i: Int) derivesFunctorcaseclassPoly[A](a: A) derivesFunctor//case class Poly11[F[_]](fi: F[Int]) derives FunctorcaseclassPoly2[A, B](a: A, b: B) derivesFunctorcaseclassPoly3[A, B, C](a: A, b: B, c: C) derivesFunctor
}
{
traitFunctorK[F[_[_]]]
objectFunctorK {
given [C] as FunctorK[[F[_]] =>>C] {}
given [T] as FunctorK[[F[_]] =>>Tuple1[F[T]]]
defderived[F[_[_]]](usingm: Mirror { typeMirroredType[X[_]] =F[X] ; typeMirroredElemTypes[_[_]] }, r: FunctorK[m.MirroredElemTypes]):FunctorK[F] =newFunctorK[F] {} // <<<<
}
caseclassMono(i: Int) derivesFunctorK//case class Poly[A](a: A) derives FunctorKcaseclassPoly11[F[_]](fi: F[Int]) derivesFunctorK//case class Poly2[A, B](a: A, b: B) derives FunctorK//case class Poly3[A, B, C](a: A, b: B, c: C) derives FunctorK
}
{
traitBifunctor[F[_, _]]
objectBifunctor {
given [C] as Bifunctor[[T, U] =>>C] {}
givenBifunctor[[T, U] =>>Tuple1[U]] {}
givent2 as Bifunctor[[T, U] =>> (T, U)] {}
givent3 [T] as Bifunctor[[U, V] =>> (T, U, V)] {}
defderived[F[_, _]](usingm: Mirror { typeMirroredType[X, Y] =F[X, Y] ; typeMirroredElemTypes[_, _] }, r: Bifunctor[m.MirroredElemTypes]):Bifunctor[F] =???
}
caseclassMono(i: Int) derivesBifunctorcaseclassPoly[A](a: A) derivesBifunctor//case class Poly11[F[_]](fi: F[Int]) derives BifunctorcaseclassPoly2[A, B](a: A, b: B) derivesBifunctorcaseclassPoly3[A, B, C](a: A, b: B, c: C) derivesBifunctor
}
}
Output
We get a crash in productMirror:
exception occurred while typechecking ../run/poly-kinded-derives.scala
exception occurred while compiling ../run/poly-kinded-derives.scala
java.lang.AssertionError: assertion failed: invalid prefix HKTypeLambda(List(X), List(TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module classscala)),classNothing),TypeRef(ThisType(TypeRef(NoPrefix,module classscala)),classAny))), AppliedType(TypeVar(TypeParamRef(F)),List(TypeParamRef(X)))) while compiling ../run/poly-kinded-derives.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: invalid prefix HKTypeLambda(List(X), List(TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module classscala)),classNothing),TypeRef(ThisType(TypeRef(NoPrefix,module classscala)),classAny))), AppliedType(TypeVar(TypeParamRef(F)),List(TypeParamRef(X))))
at dotty.DottyPredef$.assertFail(DottyPredef.scala:17)
at dotty.tools.dotc.core.Types$NamedType.<init>(Types.scala:1870)
at dotty.tools.dotc.core.Types$TypeRef.<init>(Types.scala:2426)
at dotty.tools.dotc.core.Types$CachedTypeRef.<init>(Types.scala:2482)
at dotty.tools.dotc.core.Uniques$NamedTypeUniques.newType$1(Uniques.scala:64)
at dotty.tools.dotc.core.Uniques$NamedTypeUniques.enterIfNew(Uniques.scala:68)
at dotty.tools.dotc.core.Types$TypeRef$.apply(Types.scala:2538)
at dotty.tools.dotc.core.Types$NamedType$.apply(Types.scala:2514)
at dotty.tools.dotc.core.Types$NamedType.withPrefix(Types.scala:2361)
at dotty.tools.dotc.core.Types$NamedType.derivedSelect(Types.scala:2294)
at dotty.tools.dotc.core.Types$TypeMap.derivedSelect(Types.scala:4873)
at dotty.tools.dotc.core.Types$ApproximatingTypeMap.derivedSelect(Types.scala:5165)
at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.op$1(TypeOps.scala:102)
at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:110)
at dotty.tools.dotc.core.TypeOps$.asSeenFrom(TypeOps.scala:55)
at dotty.tools.dotc.core.Types$Type.asSeenFrom(Types.scala:901)
at dotty.tools.dotc.core.Types$Type.memberInfo(Types.scala:893)
at dotty.tools.dotc.typer.Synthesizer.$anonfun$3(Synthesizer.scala:282)
at scala.collection.immutable.List.map(List.scala:223)
at dotty.tools.dotc.typer.Synthesizer.productMirror(Synthesizer.scala:282)
Expectation
Should compile.
The text was updated successfully, but these errors were encountered:
Minimized code
This is a version of the test tests/run/poly-kinded-derives.scala where all type parameters are made explicit. The critical change is in the the line marked // <<<<
Output
We get a crash in productMirror:
Expectation
Should compile.
The text was updated successfully, but these errors were encountered: