+
Skip to content

Conversation

reimai
Copy link
Contributor

@reimai reimai commented May 30, 2024

Code generated by ZLayer's macros' is slightly different between compilations, the order of definitions and layer variable's names keep changing.
We're using bazel as a build tool and it's important for build to produce an exact same file for the same input, otherwise it's dependent targets are re-evaluated.

@CLAassistant
Copy link

CLAassistant commented May 30, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@kyri-petrou kyri-petrou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks okay to me. Out of curiosity, what is the issue you faced with the previous behaviour?

Edit: nevermind me it's in the description 😅

Comment on lines +87 to +92
val memoList: List[(LayerExpr, LayerExpr)] =
tree.toList.map { node =>
val freshName = c.freshName("layer")
val termName = TermName(freshName)
node -> c.Expr(q"$termName")
}.toMap
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do a .distinct after the toList just to make sure we don't have duplicates or no need?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LayerTree#toList still does a fold into a Set (a LinkedHashSet this time, to keep an order), thus producing a distinct output, so no need for an explicit call to .distinct

@kyri-petrou
Copy link
Contributor

@reimai before I approve, do the Scala 3 macros need to be changed as well?

@reimai
Copy link
Contributor Author

reimai commented May 31, 2024

@reimai before I approve, do the Scala 3 macros need to be changed as well?

This fix covers scala 3 version of zio, as it reuses the same LayerTree class with updated toList method. My local test for scala3 compiles to the exact same classfiles after the fix.

@kyri-petrou kyri-petrou merged commit 46214a2 into zio:series/2.x May 31, 2024
@KostadinAlmishev
Copy link

@kyri-petrou Release, please, new version with these changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载