-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Extension methods with recursive implicit resolution do not work #7056
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
Comments
We'd need a better minimization here. What extension method call should have been synthesized? |
@odersky I minimized this as follows: type A
type B <: A
type PartialId[X] = X match {
case B => X
}
trait T1[T] {
extension (t1: T) def idnt1: Any
}
given [T <: A](using PartialId[T]): T1[T] = new T1[T] {
extension (t1: T) def idnt1: Any = ???
}
given PartialId[B] = ???
val x: B = ???
val z = x.idnt1 Out: -- [E008] Member Not Found Error: ../pg/i7056/Main.scala:19:10 -----------------
19 |val z = x.idnt1
| ^^^^^^^
| value idnt1 is not a member of B.
| An extension method was tried, but could not be fully constructed:
|
| Main$package.T1_T_given[A](PartialId_B_given).idnt1()
one errors found To make it work, define type PartialId[X] = X match {
case _ => X
} Also, if you leave // val x: B = ???
// val z = x.idnt1
val a = the[T1[B]] Note what the error message says: Main$package.T1_T_given[A] The argument to My guess is that the match type that matches against a non-wildcard pattern messes up the precision of the type inference. And it does so only for the extension methods, as demonstrated by the Related to #7078? |
Another way to make the example work is to define the second given as: given as PartialId[A] = ??? Which supports the hypothesis that the inference happens for the upper bound and not for the actual type argument. |
I believe this is a duplicate of #8311 |
Since #8311 is closed, we should do the same here. |
Says:
But:
Works. My gut feeling tells me it is related to #7049 and #7050.
The text was updated successfully, but these errors were encountered: