[2.13.2-bin-ca30256] scala.reflect.internal.Types$TypeError: type mismatch #11936
Open
Description
reproduction steps
Try to compile the following with 2.13.2-bin-ca30256:
object MTrie {
type Trie[K, V] = Map[K, Node[K, V]]
sealed abstract class Node[K, V] {
def fold[A](b: Branch[K, V] => A, t: Value[K, V] => A): A = ???
}
final case class Branch[K, V](value: Option[Value[K, V]], next: Trie[K, V]) extends Node[K, V]
final case class Value[K, V](value: V) extends Node[K, V]
implicit class Ops[K, V](val trie: MTrie.Trie[K, V]) extends AnyVal {
type Node = MTrie.Node[K, V]
def foldl[A](z: A)(f: (A, K, Node) => A): A =
???
def cataN[A](z: A)(f: (A, Node) => A): A =
foldl(z)((q, _, n) =>
n.fold(
b => b.next.cataN(f(q, n))(f),
_ => f(q, n)))
}
}
problem
[info] Compiling 1 Scala source to /tmp/shipreq.sbt/base-util/jvm/target/scala-2.13/classes ...
[error] ## Exception when compiling 66 sources to /tmp/shipreq.sbt/base-util/jvm/target/scala-2.13/classes
[error] scala.reflect.internal.Types$TypeError: type mismatch;
[error] found : (A, $this.Node) => A
[error] (which expands to) (A, MTrie.Node[K,V]) => A
[error] required: (A, MTrie.Node[K,V]) => A
expectation
It should compile successfully. It does with Scala 2.12.