-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Finding implicit Tag fails sometimes for generic type argument #8834
Comments
/bounty $100 |
💎 $100 bounty • ZIOSteps to solve:
Thank you for contributing to zio/zio! Add a bounty • Share on socials
|
Index: core/shared/src/main/scala-3/zio/internal/macros/LayerMacroUtils.scala
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/core/shared/src/main/scala-3/zio/internal/macros/LayerMacroUtils.scala b/core/shared/src/main/scala-3/zio/internal/macros/LayerMacroUtils.scala
--- a/core/shared/src/main/scala-3/zio/internal/macros/LayerMacroUtils.scala (revision b9f54f5211389cf2fb807c3774f400e7ed336339)
+++ b/core/shared/src/main/scala-3/zio/internal/macros/LayerMacroUtils.scala (date 1716157106781)
@@ -1,8 +1,9 @@
package zio.internal.macros
-import zio._
-import scala.quoted._
-import scala.compiletime._
+import zio.*
+
+import scala.quoted.*
+import scala.compiletime.*
import zio.internal.macros.StringUtils.StringOps
import zio.internal.ansi.AnsiStringOps
@@ -61,7 +62,11 @@
case '{$lhs: ZLayer[i, e, o]} =>
rhs match {
case '{$rhs: ZLayer[i2, e2, o2]} =>
- '{$lhs.++($rhs)}
+ Expr.summon[Tag[o2]] match {
+ case Some(t) =>
+ '{$lhs.++($rhs)(using $t)}
+ case _ => throw new Error("OptionalImplicit should be always available")
+ }
}
} Seems to fix it, but I hate it. Maybe it's compiler problem? EDIT: Yeah - it seems that compiler will take the most outer implicit instead of closest one EDIT2: I've asked on users forum about that: https://users.scala-lang.org/t/scala-3-when-calling-method-with-implicit-value-within-quotes-implicit-in-scope-is-not-found/10003 EDIT3: I believe the message is not from |
/attempt #8834
|
💡 @andrzejressel submitted a pull request that claims the bounty. You can visit your bounty board to reward. |
I couldn't find a pattern why these errors are happening.
ZIO: 2.0 and 2.1
Scala: 3.3 and 3.4
Example1
https://scastie.scala-lang.org/YYk2KAU0T8e51QTozYJZeg
Commenting either line 11 or 12 fixes the issue. Replacing
MyC
with empty trait also fixes it.Example 2
https://scastie.scala-lang.org/cuewZKmkT8mE0lOldDBcZw
Here the existence of
Unit
layer (like Logging ones) breaks stuff. MakinganotherLayer
return type non-Unit or extractingMyC
to empty trait fixes.At the beginning I thought it has to do with number of abstract arguments, but that's not the case: https://scastie.scala-lang.org/6h5rekHNSZKybKnOEMYO2A
Error for SEO:
The text was updated successfully, but these errors were encountered: