scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.88k stars 1.06k forks source link

Typer regression in `business4s/decisions4s` #21981

Open WojciechMazur opened 3 days ago

WojciechMazur commented 3 days ago

Based on OpenCB failure in business4s/decisions4s - build logs

Compiler version

Last good release: 3.6.3-RC1-bin-20241111-b712447-NIGHTLY First bad release: 3.6.3-RC1-bin-20241112-6f48c39-NIGHTLY Bisect points to 0a04b68eeda258e7fb3cec8551c19d49c4292679

Minimized code

object internal:
  trait Functor[F[_]] {
    extension [T](ft: F[T]) def map[T1](f: T => T1): F[T1]
  }

object cats:
  trait Functor[F[_]]
  object Functor:
    trait Ops[F[_], A]:
      def map[B](f: A => B): F[B] = ???
    def toAllFunctorOps[F[_], A](target: F[A])(using Functor[F]): Ops[F, A] = ???

given [F[_]](using cf: cats.Functor[F]): internal.Functor[F] with {
  extension [T](ft: F[T]) def map[T1](f: T => T1): F[T1] = ???
}

trait Ref[F[_], +T]
class MemoizingEvaluator[Input[_[_]], Output[_[_]], F[_]: cats.Functor] {
  type OptionRef[T] = Ref[F, Option[T]]

  def sequence[CaseClass[_[_]], G[_], H[_]](instance: CaseClass[[t] =>> G[H[t]]]): G[CaseClass[H]] = ???
  def collectValues(input: Input[F]): F[(Input[F], Input[OptionRef])] = {
    val refsF: Input[[t] =>> F[OptionRef[t]]] = ???
    for {
      refs <- cats.Functor.toAllFunctorOps(sequence[Input, F, OptionRef](refsF))
      updating = ???
    } yield (updating, refs)
  }
}

Output

-- [E007] Type Mismatch Error: /Users/wmazur/projects/scala/sandbox/test.scala:27:13 ----------------------------------------------------------------------------------------------------------
27 |    } yield (updating, refs)
   |             ^^^^^^^^
   |             Found:    (updating : Any)
   |             Required: Input[F]
   |
   |             where:    F     is a type in class MemoizingEvaluator with bounds <: [_] =>> Any
   |                       Input is a type in class MemoizingEvaluator with bounds <: [_²[_$8]] =>> Any
   |
   | longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: /Users/wmazur/projects/scala/sandbox/test.scala:27:23 ----------------------------------------------------------------------------------------------------------
27 |    } yield (updating, refs)
   |                       ^^^^
   |                       Found:    (refs : Any)
   |                       Required: Input[MemoizingEvaluator.this.OptionRef]
   |
   |                       where:    Input is a type in class MemoizingEvaluator with bounds <: [_[_$8]] =>> Any
   |
   | longer explanation available when compiling with `-explain`

Expectation

Should compile