Skip to content

StackOverflow in implicit search (getParts) #11775

Open
@adriaanm

Description

@adriaanm
trait Cmp[T] { def compareTo(o: T): Int }
class K[T] extends Cmp[K[_ >: T]] { def compareTo(that: K[_ >: T]): Int = ??? }

object Tst {
  (new K[String]).compareTo(new K[Int])
}

stack overflows in 2.13.x -- haven't checked older versions

+ marks the spot

--- i/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ w/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -1367,6 +1367,7 @@ trait Implicits {
        */
       def getParts(tp: Type)(implicit infoMap: InfoMap, seen: mutable.HashSet[Type], pending: Set[Symbol]): Unit = {
         if (seen add tp) tp match {
+//          case _ if seen exists (_ =:= tp) => println(s"already had $tp in $seen")
           case TypeRef(pre, sym, args) =>
             if (sym.isClass && !sym.isRoot &&
                 (isScala213 || !sym.isAnonOrRefinementClass)) {

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions