Skip to content

Out of memory while producing Type Mismatch error message #5327

Closed
@panacekcz

Description

@panacekcz

This code (based on i3965.scala; notice the added intersection) should not compile. However, the compiler seems to get in some sort of infinite recursion, runs for a few minutes and then fails with Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded.

trait T
trait SortedSetOps[CC[X], C]
class TreeSet[A] extends SortedSetOps[TreeSet, TreeSet[A]]

class Test {
  def optionSequence1[CC[X] <: (SortedSetOps[CC, CC[X]] & T) , A](xs: CC[A]): Unit = ()
  def test(xs2: TreeSet[String]) = {
    optionSequence1(xs2)
  }
}

(If & T is removed, or with T is added to TreeSet, it compiles fine.)

This variant also fails, but it possibly could compile by inferring CC to be [X] => (TreeSet[X] & T):

trait T
trait SortedSetOps[CC[X], C]
class TreeSet[A] extends SortedSetOps[[X] => (TreeSet[X] & T), TreeSet[A] & T]

class Test {
  def optionSequence1[CC[X] <: (SortedSetOps[CC, CC[X]] & T) , A](xs: CC[A]): Unit = ()
  def test(xs2: TreeSet[String] & T) = {
    optionSequence1(xs2)
  }
}

When the type parameters are specified explicitly, optionSequence1[[X] => (TreeSet[X] & T), String](xs2), it compiles fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:reportingError reporting including formatting, implicit suggestions, etcitype:bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions