Skip to content

Regression in typer for zio-archive/zio-connect #23611

@WojciechMazur

Description

@WojciechMazur

Based on failure in OpenCB for zio-archive/zio-connect Open CB logs

Compiler version

Last good release: 3.7.3-RC1-bin-20250717-fb66af2-NIGHTLY
First bad release: 3.7.3-RC1-bin-20250718-42fdd76-NIGHTLY
Bisect points to e6bf7b8 / #23532

Minimized code

import java.io.{File, IOException}
import java.net.URI
import java.nio.file.{Path, Paths}
import scala.reflect.ClassTag

trait FileConnectors { 
  def listPath(path: => Path): ZStream[Any, IOException, Path]

  final def listFile(file: => File): ZStream[Any, IOException, File] =
    for {
      path <- null.asInstanceOf[ZStream[Any, IOException, Path]]
      r    <- listPath(path).mapZIO(a => ZIO.attempt(a.toFile).refineToOrDie)
    } yield r
}

sealed trait ZIO[-R, +E, +A]
extension [R, E <: Throwable, A](self: ZIO[R, E, A])
  def refineToOrDie[E1 <: E: ClassTag]: ZIO[R, E1, A] = ???

object ZIO:
  def attempt[A](code: => A): ZIO[Any, Throwable, A] = ???
  
sealed trait ZStream[-R, +E, +A]:
  def map[B](f: A => B): ZStream[R, E, B] = ???
  def flatMap[R1 <: R, E1 >: E, B](f: A => ZStream[R1, E1, B]): ZStream[R1, E1, B]
  def mapZIO[R1 <: R, E1 >: E, A1](f: A => ZIO[R1, E1, A1]): ZStream[R1, E1, A1]

Output

-- [E007] Type Mismatch Error: /Users/wmazur/projects/scala/community-build3/example.scala:12:6 
12 |      r    <- listPath(path).mapZIO(a => ZIO.attempt(a.toFile).refineToOrDie)
   |      ^
   |      Found:    ZStream[Any, Throwable, java.io.File]
   |      Required: ZStream[Any, java.io.IOException, java.io.File]
13 |    } yield r
   |
   | longer explanation available when compiling with `-explain`
1 error found
Compilation failed

Expectation

Should compile

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions