scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

Incorrect subtype evidence #12708

Open Mee-Tree opened 1 year ago

Mee-Tree commented 1 year ago

Reproduction steps

Scala version: 2.13.10

implicitly[{
  type T[_[_]]
} =:= {
  type T[_[X] <: Iterable[X]]
}]

Problem

Somehow the compiler finds an implicit for all of these: <:<, =:=, and >:> (defined like type >:>[+A, -B] = <:<[B, A]).

However, the only correct option is:

implicitly[{
  type T[_[_]]
} <:< {
  type T[_[X] <: Iterable[X]]
}]

The code works as expected in Scala 3.

lrytz commented 1 year ago

Relevant comment in dotty: https://github.com/lampepfl/dotty/blob/3.2.1/compiler/src/dotty/tools/dotc/core/TypeComparer.scala#L686-L709