Open
Description
reproduction steps
using Scala 2.13.42.13.6,
trait Chain
class ~[I <: Chain, L] extends Chain
class @~ extends Chain
trait Factory[+R[_]] {
def m[T]: R[T]
}
trait GenericExpansion[K <: Chain, E[_ <: Chain]] extends Factory[({ type R[X] = E[K ~ X] })#R]
trait Instance[K <: Chain] extends GenericExpansion[K, Instance]
trait FFactory[+R[_]] {
def f[X]: R[X]
}
trait F extends FFactory[({ type R[X] = Instance[@~ ~ X] })#R]
trait Test[X] {
def m(x: X, y: X): X = m(x)
def m(x: X): X = x
def m(i: Int): F
}
problem
If you comment out trait Test
, everything seems ok. That is, except random pieces of code using F
in completly legal ways you get a StackOverflowException
. In Test
, the problem is the m(x)
call in presence of overloads of the same shape(?). In the original, the types weren't even generic, but unrelated. Should F
compile at all? If not, is the whole problem approached by this code unsolvable in general?