-
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
False positive warning for new implicit resolution rules in 3.5.0-RC3 #21036
Comments
//> using scala 3.5.0-RC3
trait SameRuntime[A, B]
trait BSONWriter[T]
trait BSONHandler[T] extends BSONWriter[T]
opaque type Id = String
object Id:
given SameRuntime[Id, String] = ???
given BSONHandler[String] = ???
given [T: BSONHandler]: BSONHandler[List[T]] = ???
given opaqueWriter[T, A](using rs: SameRuntime[T, A], writer: BSONWriter[A]): BSONWriter[T] = ???
val x = summon[BSONHandler[List[Id]]] // this doesn't emit warning
val y = summon[BSONWriter[List[Id]]] // this does emit warning
|
The reproduction from the first post emits the warning on current |
Isn't that a minimization of one of the known failures in reactive mongo. In that case the warning would be correct: implicit resolution will change. I'll verify that this is indeed the case. |
No, it's not the case, If I compile this with |
Minimization: //> using options -source:3.5
given Int = 1
trait A[T]
trait B[T] extends A[T]
given b[T](using Int): B[List[T]] = ???
given a[T](using String): A[T] = ???
val x = summon[B[List[String]]] // no warning
val y = summon[A[List[String]]] // warning Note the order of declarations of |
I think I found it. We call compareAlternatives in disambiguate, to drop more pending candidates. In that case, we should issue a warning only if the pending candidate is in the final result, not the candidate that was found so far. |
also #20572 |
For the record: I have experienced this warning with RC3 in my project using borer library. Same as here, the warning disappeared when using There were many warnings with RC3, some contained implicit evidence in both alternatives, some not:
Unless proven otherwise, I assume all those warnings were false, caused by this RC3 issue. |
If the warning disappeared in RC4, it definitely was a false positive. |
Compiler version
3.5.0-RC3
Minimized code
Output
Expectation
It shouldn't emit any warnings, as there is no implicit evidence for the second case. Also if we enabled
//> using options -source:3.6-migration
it works perfectly.Related discussions: #19300 and #20484
The text was updated successfully, but these errors were encountered: