Skip to content

Type parameter inference fails when it's only constrained by a wildcard #2397

Closed
@olafurpg

Description

@olafurpg

The following code compiles with Scala 2.x

package bar
import java.nio.file._
import java.util.stream.Collectors
object foo {
  Files.walk(Paths.get("")).collect(Collectors.toList[Path])
}

while dotc at commit 5093126 reports a type error

-- [E007] Type Mismatch Error: foo.scala:5:36 ----------------------------------
5 |  Files.walk(Paths.get("")).collect(Collectors.toList[Path])
  |                                    ^^^^^^^^^^^^^^^^^^^^^^^
  |       found:    java.util.stream.Collector[java.nio.file.Path, _,
  |         java.util.List[java.nio.file.Path]
  |       ]
  |       required: java.util.stream.Collector[_ >: java.nio.file.Path, A, R]
  |
  |       where:    A is a type variable
  |                 R is a type variable

one error found

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions