Skip to content

Add support for Scala version specific sources in compiler interface #681

@gkossakowski

Description

@gkossakowski

Sbt managed to maintain one code base for the compiler interface project that was shared across all version of Scala compiler. The compiler interface is responsible for interacting with Scala compiler internals that perform dependency tracking and API extraction. It managed to maintain source compatibility by applying various trick that can be seen here:
https://github.com/sbt/sbt/blob/0.13/compile/interface/src/main/scala/xsbt/Analyzer.scala#L126

However, with the work I'm doing to track dependencies in a more fine-grained way we'll hit the wall of not being able to for example support dependency tracking for macros and supporting 2.9 compiler at the same time. See this thread on scala-internals for initial discussion about how to achieve that.

We can still share most of the code of compiler interface but we'll definitively need some custom code per Scala major version. It's worth noting that sbt already ships precompiled versions of the compiler interface so that part wouldn't be affected (apart from the fact that compilation of precompiled interface would need to chose the right version of certain sources). The more tricky problem is with artifact that stores compiler interface sources and is being used in case precompiled interface is missing for particular version of Scala compiler. We have two choices:

  • Support only latest major release when it comes to compiler-interface-src artifact so we ship only one version like right now and it only works with latest major version of Scala at the time sbt was released;
  • Include version number of major version Scala compiler in name of compiler-interface-src artifact as it's done with any other cross-versioned artifact

One way or another this seems like fairly involved refactoring so I'm filing a ticket for that.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions