Skip to content

Good code is red. Java interop issue with collectors #19637

@SimY4

Description

@SimY4

Compiler version

Reproducible on 3.4.0-RC4. This code works fine on 3.3.1

Minimized code

import java.util.stream.*
import java.util.function.*

val map: java.util.Map[String, String] = Stream.of("1", "2", "3").collect(Collectors.toMap(
  (s: String) => s,
  Function.identity(),
  {
    case ("1", "1") => "1"
    case (_, l) => l
  }
))

Output

Found:    ("1" : String)
Required: Nothing

Expectation

Should compile

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions