Commit eb84bdd
authored
Take into account the result type of inline implicit conversions unless 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 #9685File tree
5 files changed
+37
-4
lines changed- community-build/community-projects
- compiler/src/dotty/tools/dotc/typer
- tests/neg-macros
5 files changed
+37
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
108 | | - | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
115 | | - | |
| 116 | + | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
0 commit comments