-
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
Regression in frawa/typed-json
for typer / implicit search
#21249
Comments
I saw a similar problem in scalameta/munit#819. This sounds expected if we instantiate type parameters before implicit search. So I guess the solution is to add type ascriptions manually. |
Further minimized: // eq.scala
class C
class D extends C
class Compare[A, B]
given [A, B](using A <:< B): Compare[A, B] = Compare()
def assertEquals[A, B](obtained: A, expected: B)(using Compare[A, B]) = ???
@main def main = assertEquals(Set(C()), Set(D()))
|
We discussed it during today's compiler meeting. I confirm the new behavior is expected. One possible workaround is to add a type ascription to the second set (or to its element): class C
class D extends C
class Compare[A, B]
given [A, B](using A <:< B): Compare[A, B] = Compare()
def assertEquals[A, B](obtained: A, expected: B)(using Compare[A, B]) = ???
@main def main = assertEquals(Set(C()), Set(D()): Set[C])
@main def main2 = assertEquals(Set(C()), Set(D(): C)) Another workaround is to define a specific class C
class D extends C
class Compare[A, B]
object Compare extends ComparePriority2:
given compare_sup[A, B](using A <:< B): Compare[A, B] = Compare()
given compare_sets[A, B](using Compare[A, B]): Compare[Set[A], Set[B]] = Compare()
trait ComparePriority2:
given compare_sub[A, B](using B <:< A): Compare[A, B] = Compare()
def assertEquals[A, B](obtained: A, expected: B)(using Compare[A, B]) = ???
@main def main = assertEquals(Set(C()), Set(D())) |
@frawa This might require changes in your codebase in the future when upgrading Scala 3 version |
Based on OpenCB failure in
frawa/typed-json
- https://github.com/VirtusLab/community-build3/actions/runs/10043516433/job/27756747215Not exactly sure if it should be fixed. The compiler is now more precise which might be an improvement. I'm not sure how to workaround it though without explicitly hinting the type
Compiler version
Since 3.4.1
Last good release: 3.4.1-RC1-bin-20240126-1716bcd-NIGHTLY
First bad release: 3.4.1-RC1-bin-20240129-b20747d-NIGHTLY
Probable cause: #19096
Minimized code
Output
Expectation
Not sure, but maybe it should still compile.
The text was updated successfully, but these errors were encountered: