scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

Restrict import suggestions or mention accessibility

Open som-snytt opened this issue 10 months ago • 2 comments

Fixes #22429

by not suggesting inaccessible extension methods unless that's all you've got.

som-snytt avatar Jan 22 '25 04:01 som-snytt

Just the accessibility test incurs a cycle.

som-snytt avatar Jan 22 '25 18:01 som-snytt

i22920.scala

//> using options -Wunused:all -Vprint:typer
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 = ???
  /*
  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] = ???
  val initializeOutbound: Async[String, String] = ???
  initializeOutbound.run:
  //delay.syntax.run(initializeOutbound):  // shows No given instance for ctx, the underlying problem
    case Success(target) => ???
    case Failure(exception) => ???
}

It suggests importing the extension, which is in implicit scope.

The messaging is slightly different in the Any version.

som-snytt avatar Apr 08 '25 09:04 som-snytt