You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- [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
The text was updated successfully, but these errors were encountered:
The issue is with the second type parameter of collect, which is x.A here. We cannot give it a more precise type because in the return type of toList it's just a Java wildcard. If we don't use an intermediate variable then we just have no way of representing it. scalac represents it as ?0 but I don't know how that works under the hood.
It's fixed with #2402. scalac is different because there types with wildcards are existentials, and existentials are unpacked before usage. The ?0 you are seeing is a skolem constant arising from unpacking.
The following code compiles with Scala 2.x
while dotc at commit 5093126 reports a type error
The text was updated successfully, but these errors were encountered: