-
-
Notifications
You must be signed in to change notification settings - Fork 307
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
Make CompilationResult
more generic
#2781
Comments
Do they even need to be the same type? It feels to me like those can be completely different |
The reason is the shared parent module |
It is completely transparent for a |
got it, that makes sense |
We have various ways to implement this:
1. Inheritancetrait CompileResult {
classes: PathRef
}
case class CompilationResult(analysisFile: os.Path, classes: PathRef) extends CompileResult
// ScalaModule
def compile: T[CompiationResult]
trait KotlinIncrDetails {
// ...
}
class KotlinCompileResult extends CompileResult with KotlinIncrDetails
// KotlinModule
def compile: T[CompileResult with KotlinIncrDetails]
// or
def compile: T[KotlinCompileResult] 2. Compositioncase class CompilationResult(
analysisFile: os.Path, // for compatibility
classes: PathRef,
extras: Map[String, AnyRef] = Map()
)
// KotlinModule
def compile: T[CompilationResult] = {
// ...
CompilationResult(
dummyFile, // what we do this currently
T.dest / "classes",
extras = Map("kotlinIncrDetails", details)
)
} I think I like 1. Inheritance more, as it might better play with upickle. But it requires a bit of discipline to use not the same def names for different Compilers, so we can better encode multiple compilers into one result (for what ever reason, e.g. an aspect compiler still able to provide incremental details). |
Inheritance with uPickle will only work if the trait is sealed. If you want jt to be extensible from downstream third party modules, you'll have to use some kind of composition |
As part of the discussion of a PR experimenting with the new scalac/zinc pipelining feature (#3202), we had the idea of realizing compilation with a set of (co-working) targets and a worker, encapsulating some compiler internals. See comment #3202 (comment) and following. |
Curent Limitations
Current
CompilationResult
is very specific for the zinc compiler.It's hard to integrate other compilers easily into Mill:
Ajc, the AspectJ compiler does not have a analysis file, we need to provide a dummy file
Kontlinc, the Kotlin compiler also has incremental compilation support, although it's currently not clear how that can be enabled in Mill, but I asssume it's via some analysis file, but with a different format that zinc
There are also other shortcomings:
Solution
Mae
ComilationResult
extensible, so that additional compiler specific details can be attached.The text was updated successfully, but these errors were encountered: