Skip to content

Regression in typer or constructor alternatives #15802

Closed
@WojciechMazur

Description

@WojciechMazur

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions