Closed
Description
This issue was minimized from the shapeless-3's new-liftp branch. The issue only occurs with separate compilation (MonoidalTest
compiles in 1.scala
, but not in 2.scala
), and the issue goes away if we inline the definition of Tuple.Size
.
tests/pos/shapeless-separate-compilation/1.scala:
package shapeless3.data
import scala.compiletime._
trait Monoidal {
type to[_] <: Tuple
type length[m] = Monoidal.length[to[m]]
}
object Monoidal {
import Tuple._
type length[m <: Tuple] = Size[m]
}
trait UnboundedMonoidal[T0[_, _], U0] extends Monoidal {
type to[t] <: Tuple = t match {
case T0[hd, tl] => hd *: to[tl]
case U0 => EmptyTuple
}
}
object pairs extends UnboundedMonoidal[Tuple2, Unit]
object MonoidalTest { // Compiles fine here
type p = (Int, (String, (Boolean, Unit)))
summon[pairs.length[p] =:= 3]
}
tests/pos/shapeless-separate-compilation/2.scala:
package shapeless3.data
object MonoidalTest2 { // But not here
type p = (Int, (String, (Boolean, Unit)))
summon[pairs.length[p] =:= 3]
}
Error:
[error] -- Error: /home/olivier/workspace/shapeless/modules/data/src/test/scala/shapeless3/data/monoidal.scala:5:9
[error] 5 | summon[pairs.length[p] =:= 3]
[error] | ^
[error] |Recursion limit exceeded.
[error] |Maybe there is an illegal cyclic reference?
[error] |If that's not the case, you could also try to increase the stacksize using the -Xss JVM option.
[error] |A recurring operation is (inner to outer):
[error] |
[error] | find-member pairs.to
[error] | find-member pairs.to
[error] | find-member pairs.to
[error] | find-member pairs.to
[error] | find-member pairs.to
[error] | find-member pairs.to
[error] | find-member pairs.to
[error] | find-member pairs.to
[error] | find-member pairs.to
[error] | find-member pairs.to
[error] | ...
[error] |
[error] | find-member pairs.to
[error] | find-member pairs.to
[error] | find-member pairs.to
[error] | find-member pairs.to
[error] | find-member pairs.to
[error] | find-member pairs.to
[error] | find-member pairs.to
[error] | find-member pairs.to
[error] | find-member pairs.to
[error] | find-member pairs.length
[error] one error found
Here is a stack trace for one iteration of the loop:
dotty.tools.dotc.core.SymDenotations$ClassDenotation.findMember(SymDenotations.scala:1964)
dotty.tools.dotc.core.Types$Type.go$1(Types.scala:655)
dotty.tools.dotc.core.Types$Type.goThis$1(Types.scala:778)
dotty.tools.dotc.core.Types$Type.go$1(Types.scala:672)
dotty.tools.dotc.core.Types$Type.findMember(Types.scala:843)
dotty.tools.dotc.core.Types$Type.memberBasedOnFlags(Types.scala:638)
dotty.tools.dotc.core.Types$Type.nonPrivateMember(Types.scala:628)
dotty.tools.dotc.core.Types$NamedType.memberDenot(Types.scala:2200)
dotty.tools.dotc.core.Types$NamedType.reload$1(Types.scala:2480)
dotty.tools.dotc.core.Types$NamedType.withPrefix(Types.scala:2493)
dotty.tools.dotc.core.Types$NamedType.derivedSelect(Types.scala:2433)
dotty.tools.dotc.core.Types$TypeMap.derivedSelect(Types.scala:5085)
dotty.tools.dotc.core.Types$ApproximatingTypeMap.derivedSelect(Types.scala:5402)
dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:102)
dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:5159)
dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:110)
dotty.tools.dotc.core.Types$TypeMap.op$proxy13$1(Types.scala:5124)
dotty.tools.dotc.core.Types$TypeMap.mapArgs(Types.scala:5124)
dotty.tools.dotc.core.Types$TypeMap.mapArgs(Types.scala:5125)
dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:5159)
dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:110)
dotty.tools.dotc.core.Types$TypeMap.op$proxy13$1(Types.scala:5124)
dotty.tools.dotc.core.Types$TypeMap.mapArgs(Types.scala:5124)
dotty.tools.dotc.core.Types$TypeMap.mapArgs(Types.scala:5125)
dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:5159)
dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:110)
dotty.tools.dotc.core.Types$TypeMap.mapOverLambda(Types.scala:5137)
dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:104)
dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:63)
scala.collection.immutable.List.mapConserve(List.scala:472)
dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:5227)
dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:110)
dotty.tools.dotc.core.Types$TypeMap.mapOverLambda(Types.scala:5137)
dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:104)
dotty.tools.dotc.core.Types$TypeMap.op$proxy15$1(Types.scala:5165)
dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:5165)
dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:110)
dotty.tools.dotc.core.TypeOps$.asSeenFrom(TypeOps.scala:55)
dotty.tools.dotc.core.Types$Type.asSeenFrom(Types.scala:995)
dotty.tools.dotc.core.Denotations$SingleDenotation.derived$1(Denotations.scala:1063)
dotty.tools.dotc.core.Denotations$SingleDenotation.computeAsSeenFrom(Denotations.scala:1076)
dotty.tools.dotc.core.Denotations$SingleDenotation.computeAsSeenFrom(Denotations.scala:1039)
dotty.tools.dotc.core.Denotations$PreDenotation.asSeenFrom(Denotations.scala:135)
dotty.tools.dotc.core.Denotations$SingleDenotation.mapInherited(Denotations.scala:1022)
dotty.tools.dotc.core.Denotations$SingleDenotation.mapInherited(Denotations.scala:1020)
dotty.tools.dotc.core.SymDenotations$ClassDenotation.collect$1(SymDenotations.scala:1956)
dotty.tools.dotc.core.SymDenotations$ClassDenotation.collect$1(SymDenotations.scala:1952)
dotty.tools.dotc.core.SymDenotations$ClassDenotation.addInherited(SymDenotations.scala:1961)
dotty.tools.dotc.core.SymDenotations$ClassDenotation.computeMembersNamed(SymDenotations.scala:1946)
dotty.tools.dotc.core.SymDenotations$ClassDenotation.membersNamed(SymDenotations.scala:1913)
dotty.tools.dotc.core.SymDenotations$ClassDenotation.membersNamedNoShadowingBasedOnFlags(SymDenotat$ons.scala:1936)
dotty.tools.dotc.core.SymDenotations$ClassDenotation.nonPrivateMembersNamed(SymDenotations.scala:1926)
dotty.tools.dotc.core.SymDenotations$ClassDenotation.findMember(SymDenotations.scala:1964)