-
Notifications
You must be signed in to change notification settings - Fork 121
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
Undercompilation when macros are used (mainargs) #1171
Comments
Here is the reproduction with
|
For the record, here's the reverse analysis of what might be happening from the Zinc PR #1316 by @Friendseeker. At https://github.com/lefou/mainargs-undercompilation-reproduction/blob/f1ee0417cab74d721063668ea5247f044870f958/foo/src/ConfigParser.scala#L7C3-L7C90 private[this] lazy val parser: ParserForClass[Config] = mainargs.ParserForClass[Config] as reported by OP. object ParserForClass extends ParserForClassCompanionVersionSpecific and for Scala 2, private[mainargs] trait ParserForClassCompanionVersionSpecific {
def apply[T]: ParserForClass[T] = macro Macros.parserForClass[T]
} Macros.parserForClass[T]The macro code looks like this https://github.com/com-lihaoyi/mainargs/blob/e1c8e25b93d1f652465dabd308aa268cb6e23696/mainargs/src-2/Macros.scala#L24-L44 def parserForClass[T: c.WeakTypeTag]: c.Tree = {
val cls = weakTypeOf[T].typeSymbol.asClass
val companionObj = weakTypeOf[T].typeSymbol.companion
val constructor = cls.primaryConstructor.asMethod
val route = extractMethod(
TermName("apply"),
constructor.paramLists.flatten,
constructor.pos,
cls.annotations.find(_.tpe =:= typeOf[main]),
companionObj.typeSignature,
weakTypeOf[T]
)
q"""
new _root_.mainargs.ParserForClass(
$route.asInstanceOf[_root_.mainargs.MainData[${weakTypeOf[T]}, Any]],
() => $companionObj
)
"""
} so in here, the If we treat expanding the scope of invalidationIf we treat I think that's what #1316 does. |
Problem
When using the macro-based CLI library mainargs, I noticed an undercompilation issue
When changing the
@doc
annotation of one argument infoo.Config
, a recompile results in only one recompiled fileConfig.scala
.The file
ConfigParser.scala
gets not recompiled, yet it contains alazy val usageText = parser.helpText()
.parser
is aprivate[this] lazy val parser: ParserForClass[Config] = mainargs.ParserForClass[Config]
.The expectation is, that also
ConfigParser.scala
gets recompiled. This does not happen. This results in an outdate/stale help message.Info to reproduce
This reproducer uses the following versions:
The reproducer: https://github.com/lefou/mainargs-undercompilation-reproduction
Steps to reproduce
@doc
annotation--help
output has not changed.expectation
The compiler should also recompile the file which depends on
Config.scala
.The text was updated successfully, but these errors were encountered: