Skip to content

Non finitary class graph passes compiler check or an unwarranted infinite recursion in typer. #12412

Open
@noresttherein

Description

@noresttherein

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    compiler crashfixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions