Skip to content

Regression in type inference since 3.0.0 #13611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
senia-psm opened this issue Sep 26, 2021 · 3 comments
Closed

Regression in type inference since 3.0.0 #13611

senia-psm opened this issue Sep 26, 2021 · 3 comments

Comments

@senia-psm
Copy link
Contributor

senia-psm commented Sep 26, 2021

Compiler version

3.0.2, 3.0.1

Code below compiles in 3.0.0 (and 2.12-2.13), but fails compilation in 3.0.2 and 3.0.1

Minimized code

Note that even replacing

val a: ZIO[Int, Nothing, Symbol]  = Get ~> c(CA())

with

val a: ZIO[Int, Nothing, Symbol]  = ???

or moving suite from top level to object or removing useless WithTransformation will fix compilation.

trait ZIO[-A, +B, +C]

trait Spec[-A, +B]

def suite[R, E, T](specs: Spec[R, E]*): Spec[R, E] = ???

trait HttpRequest

trait RequestContext
trait RouteResult

case class CA()

object CA {
  implicit val aEv: Ev[CA] = ???
}

trait CB

trait Ev[T]

object CB {
  implicit def apply[T](a: T)(implicit ev: Ev[T]): CB = ???
}

def c(b: CB): RequestContext => Option[RouteResult] = ???

object RouteDefaultRunnableSpec {
  def assertM[R, E, A](effect: ZIO[R, E, A]): ZIO[R, E, String] = ???

  def testM[R, E](assertion: => ZIO[R, E, String]): Spec[R, E] = ???

  val Get: HttpRequest = ???

  implicit class WithTransformation(request: HttpRequest) {
    def ~>(f: HttpRequest => HttpRequest): HttpRequest = f(request)
  }

  implicit class WithRoute(request: HttpRequest) {
    def ~>(route: RequestContext => Option[RouteResult]): ZIO[Int, Nothing, Symbol] = ???
  }

  def spec =
    suite(
      testM {
        val a: ZIO[Int, Nothing, Symbol]  = Get ~> c(CA())
        val res: ZIO[Int, Nothing, String] = assertM(a)
        res
      },
    )
}

Output

[error] -- [E007] Type Mismatch Error: /file/path/something.scala:48:8 
[error] 48 |        res
[error]    |        ^^^
[error]    |        Found:    (res : ZIO[Int, Nothing, String])
[error]    |        Required: ZIO[Any, Any, String]

Expectation

Code should be compilable. Compilation of this code should not depend on val implementation if type of val is specified manually.

@senia-psm senia-psm changed the title Regression in type inference cince 3.0.0 Regression in type inference since 3.0.0 Sep 26, 2021
@senia-psm
Copy link
Contributor Author

Originally found here: senia-psm/zio-test-akka-http#77

@smarter
Copy link
Member

smarter commented Sep 26, 2021

This regressed in #12519

@smarter
Copy link
Member

smarter commented Sep 26, 2021

... but it's actually already fixed in 3.1.0-RC1 (and -RC2), apparently by #13361

@smarter smarter closed this as completed Sep 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants