Skip to content

Regression in apache/incubator-pekko - invalid type inference #19001

Closed
@WojciechMazur

Description

@WojciechMazur

Based on Open CB failure for apache/incubator-pekko - build logs

Compiler version

Since 3.4.0-RC1-bin-20231113-0dfe593-NIGHTLY

Bisect points to a196167

Minimized code

import java.util.concurrent.CompletionStage
import scala.concurrent.Future


trait ActorRef[-T]{
   def ask[Res](replyTo: ActorRef[Res] => T): Future[Res] = ???
}


implicit final class FutureOps[T](private val f: Future[T]) extends AnyVal {
  def asJava: CompletionStage[T] = ???
}

class AskPattern[Req, Res] {
  val actor: ActorRef[Req] = ???
  val messageFactory: ActorRef[Res] => Req = ???

  def failing(): CompletionStage[Res] = actor.ask(messageFactory.apply).asJava
  def workaround1(): CompletionStage[Res] = actor.ask[Res](messageFactory.apply).asJava
  def workaround2(): CompletionStage[Res] = actor.ask(messageFactory).asJava

  val jMessageFactory: java.util.function.Function[ActorRef[Res], Req] = ???
  def originalFailingCase(): CompletionStage[Res] = actor.ask(jMessageFactory.apply).asJava
}

Output

-- [E007] Type Mismatch Error: /Users/wmazur/projects/dotty/bisect/main.scala:18:72 
18 |  def failing(): CompletionStage[Res] = actor.ask(messageFactory.apply).asJava
   |                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |                     Found:    java.util.concurrent.CompletionStage[Any]
   |                     Required: java.util.concurrent.CompletionStage[Res]
   |
   | longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: /Users/wmazur/projects/dotty/bisect/main.scala:23:84 
23 |  def originalFailingCase(): CompletionStage[Res] = actor.ask(messageFactory.apply).asJava
   |                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |                     Found:    java.util.concurrent.CompletionStage[Any]
   |                     Required: java.util.concurrent.CompletionStage[Res]
   |

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