Skip to content

Invalid parsing of partial function under relaxedLambdaSyntax #24496

@WojciechMazur

Description

@WojciechMazur

Compiler version

3.8.0-RC1

Minimized code

import scala.language.experimental.relaxedLambdaSyntax

@main def Test =
  val list = List(1, 2, 3)
  val one = list
        .collect: case x => (x, x + 1)
        .toMap

  val two = list
        .collect: x => (x, x + 1)
        .toMap

Output

[error] ./test.scala:6:29
[error] value toMap is not a member of (Int, Int)

-Vprint:typer output

scala compile -S 3.8.0-RC1 test.scala -Vprint:typer
Compiling project (Scala 3.8.0-RC1, JVM (21))
[error] ./test.scala:6:29
[error] value toMap is not a member of (Int, Int)
[[syntax trees at end of                     typer]] // /Users/wmazur/projects/scala/community-build3/test.scala
package <empty> {
  import scala.language.experimental.relaxedLambdaSyntax
  final lazy module val test$package: test$package = new test$package()
  final module class test$package() extends Object() {
    this: test$package.type =>
    @main def Test: Unit =
      {
        val list: List[Int] = List.apply[Int]([1,2,3 : Int]*)
        val one: List[Nothing] =
          list.collect[Nothing]((x$1: Int) =>
            x$1 match 
              {
                case x @ _ => Tuple2.apply[Int, Int](x, x + 1).toMap
              }
          )
        val two: Map[Int, Int] =
          list.collect[(Int, Int)]((x: Int) => Tuple2.apply[Int, Int](x, x + 1))
            .toMap[Int, Int](<:<.refl[(Int, Int)])
        ()
      }
  }
}

Expectation

Should compile

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions