Skip to content
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

millModuleDirectChildren is not respected when resolving #2573

Closed
lolgab opened this issue Jun 6, 2023 · 3 comments · Fixed by #2574
Closed

millModuleDirectChildren is not respected when resolving #2573

lolgab opened this issue Jun 6, 2023 · 3 comments · Fixed by #2574
Labels
bug The issue represents an bug
Milestone

Comments

@lolgab
Copy link
Member

lolgab commented Jun 6, 2023

Given this build:

import mill._
object mod extends Module {
  override lazy val millModuleDirectChildren = Seq.empty[Module]
  object bar extends Module
  object foo extends Module
}

mill resolve mod._

returns mod.bar and mod.foo in 0.11.0-M11 while doesn't return anything in 0.10.12

@lolgab lolgab added the bug The issue represents an bug label Jun 6, 2023
@lihaoyi
Copy link
Member

lihaoyi commented Jun 6, 2023

The new resolver aims to avoid instantiating things as far as possible, so it doesn't even look at millModuleDirectChildren and just uses the java.lang.Class for resolution.

We can make this work again by introducing a marker trait, perhaps DynamicChildren, to indicate to Mill that we should actually instantiate the module and look at its children. This would be similar to what we do for Cross modules

@lolgab
Copy link
Member Author

lolgab commented Jun 6, 2023

What I really need is a def enabled: Boolean = true in Module so users and plugins can dynamically disable modules based on conditions. Redefining millModuleDirectChildren was what was possible in Mill 0.10.

lihaoyi added a commit that referenced this issue Jun 7, 2023
…duleDirectChildren` (#2574)

Fixes #2573

For now, I just preserved the `def millModuleDirectChildren` overriding.
I couldn't figure out how to get `def enabled: Boolean` working without
causing circular dependencies between `instantiateModule` depend on
`resolveDirectChildren0`, resulting in an infinite recursion. Avoiding
the infinite recursion would require some re-working on
`ResolveCore.scala`. That can come in a follow-up, for now I just want
to fix the regression and preserve the status quo (except for the new
requirement of needing to extend a marker trait)
@lefou lefou added this to the 0.11.0 milestone Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue represents an bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants