Skip to content

Regression in akka/akka for type inference of partial functions #21676

Closed
@WojciechMazur

Description

@WojciechMazur

Based on OpenCB failure in akka/akka - build logs

Compiler version

Last good release: 3.6.0-RC1-bin-20240920-4293a45-NIGHTLY
First bad release: 3.6.0-RC1-bin-20240922-22ed2fb-NIGHTLY
Bisect points to b410f30

Minimized code

@main def Test = 
  val members = collection.immutable.SortedSet.empty[String]
  members.collect {
    var upNumber = 0
    {
      case m => 
        // upNumber += 1
        m
    }
  }

Output

-- [E007] Type Mismatch Error: /Users/wmazur/projects/sandbox/test.scala:3:18 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 3 |  members.collect {
   |                  ^
   |                  Found:    String => String
   |                  Required: PartialFunction[String @uncheckedVariance, Any]
 4 |    var upNumber = 0
 5 |    {
 6 |      case m => 
 7 |        // upNumber += 1
 8 |        m
 9 |    }
10 |  }
   |
   | longer explanation available when compiling with `-explain`

Expectation

Should infer correct type a partial function instead of regular function

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions