-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Comparing Chunk to Seq causes ClassCastException #8754
Comments
I believe it's caused by case Unseal(MethodCall(lhs, "==", tpes, Some(List(rhs)))) =>
val span = getSpan(rhs)
lhs.tpe.widen.asType match {
case '[l] =>
Expr.summon[OptionalImplicit[Diff[l]]] match {
case Some(optDiff) =>
'{${transform(lhs.asExpr)} >>> SmartAssertions.equalTo(${rhs.asExpr})($optDiff.asInstanceOf[OptionalImplicit[Diff[Any]]]).span($span)}.asExprOf[TestArrow[Any, A]]
case _ => throw new Error("OptionalImplicit should be always available")
}
} lhs should be first common class (GCD of class I guess) |
/bounty $50 |
💎 $50 bounty • ZIOSteps to solve:
Thank you for contributing to zio/zio! Add a bounty • Share on socials
|
I was wrong with my initial checks - Chunk and Seq are related. It just required proper mapping logic like in Scala 2.13 |
LUB and GLB are not exposed in Scala 3 macros. You could make |
I was writing that before i knew how Scala 2 macro work - it should propably work like it. So one class has to be subtype of another.
|
Not sure what you mean. This is Scala 3.
Nope, LUB doesn't require one class to be subtype of the other. |
I meant that |
S3 unfortunately does allow it and it generate pretty ugly comparisons - I think I would prefer for it to be reported during compilation. |
They are related though, |
Yes, this specific issue is about directly related classes (which I didn't know at the beginning) and I want to focus on that. The issue with non directly related classes is that they are all ultimately related anyway thought Any (which have diff instance). And I like Scala 2 behavior of not allowing comparisons of non directly related classes. |
Maybe it just my thing - but when I'm comparing A to option A or Seq A, I'd rather have compile error than downcast to Any. |
Scala 3 (2.13 does not compile with
found Seq, require Chunk
error)Both 2.0 and 2.1-RC
https://scastie.scala-lang.org/7CX9Y9D3QYq0v4TNcsIDmw
The text was updated successfully, but these errors were encountered: