-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Confusing suggested import involving inline implicit #9685
Comments
I've seen this problem before with another |
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 The |
Closes scala#9685
@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. |
Closes scala#9685
Looks like we have a new case that's failing: |
…ss they are transparent Fixes scala#9685
…ss they are transparent (#17924) In the first commit, I add a failing test: ~~~ scala import scala.language.implicitConversions class Foo object Foo: inline implicit def toFoo(x: Int): Foo = Foo() object Usage: 1.asdf // error ~~~ We expect that code to not compile but the error reported by the compiler is confusing as it suggests importing `Foo.toFoo` to resolve the compilation error. You can see this in the [test report](https://github.com/lampepfl/dotty/actions/runs/5254687053/jobs/9493612604#step:9:1859). The problem comes from the fact that currently when the compiler checks whether an implicit conversion is applicable to an expression that fails to compile, it does not take into account the expected result type (here, `? { def asdf: ? }`) if the candidate is an `inline` definition. Instead, I believe the expected result type should be taken into account unless the candidate is a `transparent inline`. I make this change in the second commit, which makes the test pass. Fixes #9685
Can the fix be backported to 3.3.x? Who should I ask for? |
We apply the full fix under `-source future` only, and a partial fix otherwise. This is a followup of scala#17924 that fixes the source incompatibilities reported in scala#18130. We test that the behavior under `-source future` still fixes scala#9685, and that without `-source future` we fix both scala#9685 and scala#18130.
We apply the full fix under `-source future` only, and a partial fix otherwise. This is a followup of scala#17924 that fixes the source incompatibilities reported in scala#18123. We test that the behavior under `-source future` still fixes scala#9685, and that without `-source future` we fix both scala#9685 and scala#18123.
We apply the full fix under `-source future` only, and a partial fix otherwise. This is a followup of scala#17924 that fixes the source incompatibilities reported in scala#18123. We test that the behavior under `-source future` still fixes scala#9685, and that without `-source future` we fix both scala#9685 and scala#18123.
We apply the full fix under `-source future` only, and a partial fix otherwise. This is a followup of scala#17924 that fixes the source incompatibilities reported in scala#18123. We test that the behavior under `-source future` still fixes scala#9685, and that without `-source future` we fix both scala#9685 and scala#18123.
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:The text was updated successfully, but these errors were encountered: