scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

Regression in typer or constructor alternatives

Open WojciechMazur opened this issue 3 years ago • 4 comments

Based on the issue found in softwaremill/tapir based on Open CB #7872

Compiler version

Works in 3.2.0-RC2 Fails in 3.2.0-RC3

Minimized code

//> using scala "3.2.0-RC3"

sealed trait ZIO[-R, +E, +A]
object ZIO{
  def fail[E](error: E): ZIO[Any, E, Nothing] = ???
}

trait Endpoint[INPUT, ERROR_OUTPUT, OUTPUT]{
  sealed trait ZServerEndpoint[R]
  def zServerLogic[R](logic: INPUT => ZIO[R, ERROR_OUTPUT, OUTPUT]): ZServerEndpoint[R] = ???
}

@main def Test() = 
  val x: Endpoint[_, Unit, Unit] = ???
  x.zServerLogic[Any](_ => ZIO.fail(new RuntimeException("boom")))

Output

[error] ./test.scala:15:41: None of the overloaded alternatives of constructor RuntimeException in class RuntimeException with types
[error]  (x$0: Throwable): RuntimeException
[error]  (x$0: String, x$1: Throwable): RuntimeException
[error]  (x$0: String): RuntimeException
[error]  (): RuntimeException
[error] match arguments (("boom" : String)) and expected result type E
[error]   x.zServerLogic[Any](_ => ZIO.fail(new RuntimeException("boom")))
[error]                                         ^^^^^^^^^^^^^^^^
Error compiling project (Scala 3.2.0-RC3, JVM)

Expectation

Should compile

WojciechMazur avatar Aug 02 '22 12:08 WojciechMazur

The commit that introduced this is: https://github.com/lampepfl/dotty/commit/b009f4276c74200923a723b1d44b00c9d6265cd4

KacperFKorban avatar Aug 02 '22 15:08 KacperFKorban

@odersky Do you have time to take a look?

Kordyjan avatar Aug 11 '22 08:08 Kordyjan

Is it urgent? I am just coming back from vacation and there's a long backlog.

odersky avatar Aug 11 '22 12:08 odersky

It can be considered a blocker for 3.2.0, as it makes it impossible to build tapir with 3.2.

Kordyjan avatar Aug 11 '22 13:08 Kordyjan