Skip to content

Extension in implicit object can no longer be used #22920

Closed as not planned
Closed as not planned
@WojciechMazur

Description

@WojciechMazur

Based on OpenCB failure in rescala-lang/rescala - build logs

Compiler version

Last good release: 3.7.1-RC1-bin-20250328-d519790-NIGHTLY
First bad release: 3.7.1-RC1-bin-20250401-d0e9062-NIGHTLY
Bisect points to 4cdeb81

Minimized code

import scala.util.*

object delay {
  class Async[-Ctx, +A]

  @FunctionalInterface
  trait Callback[-A] {
    def complete(tr: Try[A]): Unit
  }

  implicit object syntax:
    extension [Ctx, A](inline async: Async[Ctx, A])
      inline def run(using inline ctx: Ctx)(inline cb: Callback[A]): Unit = ???
}


@main def Test = {
  import delay.Async
  val initializeOutbound: Async[Any, String] = ???
  initializeOutbound.run:
    case Success(target) => ???
    case Failure(exception) => ???
}

Output

[error] ./test.scala:20:3
[error] Found:    (initializeOutbound : delay.Async[Any, String])
[error] Required: ?{ run: ? }
[error] Note that implicit conversions were not tried because the result of an implicit conversion
[error] must be more specific than Ctx
[error]   initializeOutbound.run:
[error]   ^^^^^^^^^^^^^^^^^^

Expectation

Not sure if this usage is covered by language specification. In such case it should be decided accessing extension in implicit object is an undefined behaviour. Otherwise should continue to compile

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions