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

Fix discovery of targets whose names get mangled due to their pseudo-private nature #2883

Merged
merged 2 commits into from
Nov 19, 2023

Conversation

lihaoyi
Copy link
Member

@lihaoyi lihaoyi commented Nov 19, 2023

Fixes #2844

Adds an integration test to cover this edge case, a few other permutations of it that I could come up with, and other private-related behavior. I'm not sure if I managed to catch all different ways these methods can be mangled, but if I missed any we can discover/add them later. This new test fails if I remove any part of the code change in GroupEvaluator.scala

I'm actually not sure if this should be an integration test or a unit test.

  • Technically this code path should be exercised in unit tests as well I think, and I think this failure mode should be triggerable.
  • But it might be affected by exactly how the defs are wrapped in nested objects/traits/classes, which is something that unit tests do not do realistically.
  • Also, a unit test cannot exercise the failure code path when you try and specify a private target from the command, since it will simply not compile (being private and all), and AFAICT this is somewhere we're missing coverage (unrelated to this specific failure mode)

So I went with integration test.

Pull request: #2883

@lihaoyi lihaoyi requested review from lefou and lolgab November 19, 2023 03:28
Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@lihaoyi lihaoyi merged commit 69b2199 into com-lihaoyi:main Nov 19, 2023
37 checks passed
@lefou lefou added this to the 0.11.6 milestone Nov 19, 2023
lefou added a commit that referenced this pull request Nov 19, 2023
We now report the target name in case we weren't able to detect it's
declaring parent class.

Tested manually with a Mill version before the merge of #2883.

```scala
// /tmp/mill-2844/build.sc
import mill._

object mod extends Module {

  object foo extends Module {
    def bar = T {
      baz()
    }
  }

  private def baz = T { "baz" }
}
```

```
> mill -i dev.run /tmp/mill-2844 -i mod.foo.bar
[1691/1691] dev.run 
[info] compiling 1 Scala source to /tmp/mill-2844/out/mill-build/compile.dest/classes ...
[info] done compiling
Could not detect the parent class of target mod.baz. Please report this at https://github.com/com-lihaoyi/mill/issues/new/choose. As a workaround, you can run Mill with `--disable-callgraph-invalidation` option.
```

Pull request: #2885
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.

Project configuration fails after migrating to 0.11.2+
2 participants