scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
230 stars 21 forks source link

Type not inferred in a .toSet.groupBy chain #12906

Closed KuceraMartin closed 7 months ago

KuceraMartin commented 7 months ago

Reproduction steps

Scala version: 2.13.11

val s = Seq(1, 2, 3, 4).toSet
val g = s.groupBy(_ % 2) // ok

val g2 = Seq(1, 2, 3, 4).toSet.groupBy(_ % 2) // won't compile

Problem

[error] missing parameter type for expanded function ((<x$2: error>) => x$2.$percent(2))
[error]   val g2 = Seq(1, 2, 3, 4).toSet.groupBy(_ % 2) // won't compile
[error]                                          ^
Error compiling project (Scala 2.13.11, JVM)
Compilation failed

It should compile.

Note: works in Scala 3

som-snytt commented 7 months ago

Duplicates https://github.com/scala/bug/issues/7743 an oldie but goodie