Skip to content

Typer regression in eed3si9n/jarjar-abrams for shadowed variable of different type #24689

@WojciechMazur

Description

@WojciechMazur

Based on failure in OpenCB for:

Found in : java.io.InputStream is a correct input type, however existance of shadowed in: java.nio.Path in the scope breaks the compilation

Compiler version

Last good release: 3.8.0-RC1-bin-20251103-714f3b6-NIGHTLY
First bad release: 3.8.0-RC1-bin-20251104-b83b3d9-NIGHTLY

Bisect points to one of:
f3aea49
5b03dca
Both are commits from #24231

Not present in 3.8.0-RCs, merged after 3.8.0 cutoff, but before change of build developed version

Minimized code

import java.io.*
import java.nio.file.*

abstract class Using[Source, A]:
  def apply[R](src: Source)(f: A => R): R = ???

object Using:
  val fileInputStream: Using[Path, InputStream] = ???

def transfer(in: Path, out: OutputStream): Unit =
  Using.fileInputStream(in)(in => transfer(in, out))

def transfer(in: InputStream, out: OutputStream): Unit = ???

Output

-- [E007] Type Mismatch Error: /Users/wmazur/projects/scala/community-build3/test.scala:12:43 
12 |  Using.fileInputStream(in)(in => transfer(in, out))
   |                                           ^^
   |                                    Found:    (in : java.io.InputStream)
   |                                    Required: java.nio.file.Path
   |
   | longer explanation available when compiling with `-explain`

Expectation

Should continue to 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