Skip to content

Commit 6ff0e6c

Browse files
authored
Fix resolution of children of override lazy val modules (#3270)
This was preventing resolution of modules in the form `override lazy val foo: FooModule = new FooModule{...}`, which are necessary when you want to override one module with another. You couldn't resolve them via `resolve` or run them from the command line, but you could depend on them from other modules and have then get picked up by planning logic These turn up in Mill's own build, and I notice I couldn't resolve e.g. `main.codesig.test.cases[callgraph-basic-1-static-method].compile` before this PR. After this PR, I can. Filtering out `abstract` methods in `Reflect` seems unnecessary, since compilation checks that every method is implemented already. Added a unit test to cover this edge case. Pull request: #3270
1 parent 862a4dc commit 6ff0e6c

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

main/define/src/mill/define/Reflect.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ private[mill] object Reflect {
2929
isLegalIdentifier(n) &&
3030
(!noParams || m.getParameterCount == 0) &&
3131
(m.getModifiers & Modifier.STATIC) == 0 &&
32-
(m.getModifiers & Modifier.ABSTRACT) == 0 &&
3332
inner.isAssignableFrom(m.getReturnType)
3433
} yield m
3534

main/resolve/test/src/mill/main/ResolveTests.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,5 +1099,12 @@ object ResolveTests extends TestSuite {
10991099
)
11001100
}
11011101
}
1102+
test("abstractModule") {
1103+
val check = new Checker(TestGraphs.AbstractModule)
1104+
test - check(
1105+
"__",
1106+
Right(Set(_.concrete.tests.inner.foo, _.concrete.tests.inner.innerer.bar))
1107+
)
1108+
}
11021109
}
11031110
}

main/test/src/mill/util/TestGraphs.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,4 +608,23 @@ object TestGraphs {
608608
}
609609
}
610610

611+
object AbstractModule extends TestUtil.BaseModule {
612+
trait Abstract extends Module {
613+
lazy val tests: Tests = new Tests {}
614+
trait Tests extends Module {}
615+
}
616+
617+
object concrete extends Abstract {
618+
override lazy val tests: ConcreteTests = new ConcreteTests {}
619+
trait ConcreteTests extends Tests {
620+
object inner extends Module {
621+
def foo = T { "foo" }
622+
object innerer extends Module {
623+
def bar = T { "bar" }
624+
}
625+
}
626+
}
627+
}
628+
}
629+
611630
}

0 commit comments

Comments
 (0)