blackdrag commented on PR #3235: URL: https://github.com/apache/groovy/pull/3235#issuecomment-7051909720
> 1. The module declaration is now a member of the compilation-unit model. `CompileUnit` holds the `ModuleInfoNode` explicitly. `ModuleInfoNode.of` reads that declaration from the class's own compile unit, or from a fallback unit when the class no longer points at its module. Node metadata is not consulted. The synthetic `module-info` carrier is still what the existing per-class pipeline visits for resolution, annotation checking, and writing `module-info.class`, but it is no longer the primary representation of the declaration. A second module declaration in the same compilation unit is rejected, and the first is kept. I started with "x\module-info.groovy is a legal source file name on linux." and was thinking more and more on the integration and I think we should go further. I think this needs to be a first class citizen. For processing the AST I see several points: * annotation processsing: I wold do this with a temporary class node if we really need one * class generation is really parallel for the module to ordinary classes, this does not really overlap * resolving imports and class usages . A simplified resolve visitor can do this. That and the real one can share infrastructure * old random AST transform should not accidently transform the module node because they think it is a normal class node * static/dynamic compilation is no question here, there is no dynamic code in a module-info class * processing pipeline: I would process the module info before normal classes on each phase and add a new phase operation for that. We also have to consider that recent PRs do a lot in the direction of testing if a class is accessible. The rules for that change if modules are involved in the sources. That is why I want the module-info be processed before the source classes in in case of the resolve visitor. I hope that also reduces the joint compilation surface > 2. The AST `CompileUnit` no longer records which class files javac produced. Those names are kept in the joint-compilation implementation, on `CompiledClassIndex`. The index includes in-memory javac output when that option is on. In that case the default snapshot does not walk the target directory, so leftover files on disk are not treated as this invocation's output, and a walk failure there cannot fail the compile. `module-info` is not added to the index. A reused compilation unit clears the index at the start of `compile`. I am not sure yet about this part. I think if we do the big changes in (1), then maybe some things here can be solved differently. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
