Skip to content

Incorrect type error when reading Scala 2.13 library #12641

Closed
@kubukoz

Description

@kubukoz

Compiler version

3.0.0

Minimized code

sbt version: 1.5.2

//build.sbt
val library = project.settings(
  scalaVersion := "2.13.6"
)

val root = project
  .in(file("."))
  .settings(
    name := "demo",
    version := "0.1.0",
    scalaVersion := "3.0.0"
  )
  .dependsOn(library)

In the library module:

package cats.effect.kernel

trait Async[F[_]]

object Async {
  trait WriterTAsync[F[_], L1]
      extends Async[({ type LL[A] = WriterT[F, L1, A] })#LL]
      with MonadCancel.WriterTMonadCancel[F, L1] {

    override def delegate = super.delegate
  }

}

case class WriterT[F[_], L0, V]()

trait MonadError[F[_]]
trait MonadCancel[F[_]]

object MonadCancel {

  trait WriterTMonadCancel[F[_], L2]
      extends MonadCancel[({ type LL[A] = WriterT[F, L2, A] })#LL] {

    def delegate: MonadError[({ type LL[A] = WriterT[F, L2, A] })#LL] =
      ???

  }
}

In the root module:

import cats.effect.kernel.Async

object demo {

  def test1[F[_]](ev: Async[F]): Unit = ???
  def test2[F[_]](ev: Async[F]): Unit = ???

}

Output

sbt:demo> compile
[info] compiling 1 Scala source to /Users/jkozlowski/IdeaProjects/scala3-12641-reproduction/library/target/scala-2.13/classes ...
[info] compiling 1 Scala source to /Users/jkozlowski/IdeaProjects/scala3-12641-reproduction/target/scala-3.0.0/classes ...
[error] -- [E023] Syntax Error: /Users/jkozlowski/IdeaProjects/scala3-12641-reproduction/src/main/scala/demo.scala:6:22
[error] 6 |  def test2[F[_]](ev: Async[F]): Unit = ???
[error]   |                      ^^^^^^^^
[error]   |             Not enough type arguments for cats.effect.kernel.Async[F, L2]
[error]   |             expected: [F, L2]
[error]   |             actual:   [F]
[error] one error found
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 17 s, completed 29 May 2021, 01:59:24

Expectation

Everything compiles fine.

Worth noting

  • this doesn't happen when only one of test1 / test2 exists!

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions