scala3
scala3 copied to clipboard
Restrict import suggestions or mention accessibility
Fixes #22429
by not suggesting inaccessible extension methods unless that's all you've got.
Just the accessibility test incurs a cycle.
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.