Open mpilquist opened 4 years ago
I've seen this problem before with another inline implicit def
. I think the suggestion mechanism believes that inline def
s can return anything, this potentially a more precise result that happens to be helpful in the given context. Whereas in fact blackbox inline defs cannot return a more specific type.
I could not reproduce it, I only get the error. @mpilquist could you write a self-contained code snipped that reproduces the issue?
@nicolasstucki I'll work on a standalone reproduction but here's an executable one in the meantime: https://scastie.scala-lang.org/bG9JkRnARomdC2pCPD5eAQ
OK this reproduces:
Clue.scala:
package foo
import scala.language.implicitConversions
class Clue[+T](val value: T)
object Clue {
import scala.quoted._
inline implicit def generate[T](value: T): Clue[T] = ${ clueImpl('value) }
def clueImpl[T:Type](value: Expr[T])(using qctx: QuoteContext): Expr[Clue[T]] = '{ new Clue($value) }
}
Main.scala:
package foo
object Main {
// If this def is removed, there's no suggestion to import Clue.generate
def toClue[A](a: A): Clue[A] = Clue.generate(a)
1.asdf
}
FWIW, we have been able to reproduce the same issue for regular implicit def
without inline
The implicit def
implementation
@olafurpg the original issue is already fixed. Could you check your use case with the current master to see if that one also got fixed? Otherwise, we should open another issue with that new scenario.
Looks like we have a new case that's failing: https://github.com/alessandrocandolini/munit-clue-confusing-suggestion
Can the fix be backported to 3.3.x? Who should I ask for?
We had to revert the commit that closed this issue to fix #19415
Minimized code
Output
Expectation
Expected:
Dotty 0.27.0-RC1 suggests
munit.Clue.generate
to fix this issue. Theclue
method andClue
class are defined as: