scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.79k stars 1.04k forks source link

Scala 2 compat testing #14922

Open nicolasstucki opened 2 years ago

nicolasstucki commented 2 years ago

We currently support the suffixes c3.x.y to allow tests to compile part of the sources with a different compiler. We should extend this to support Scala 2 as we have many issues related to compatibility that are not simple.

The idea is to be able to write these tests

// tests/pos/mytest/A_1_c2.13.8.scala
class Foo // Foo compiled with Scala 2
// tests/pos/mytest/B_2.scala
class Bar extends Foo // Foo used in Scala 3
nicolasstucki commented 2 years ago

@prolative, where do we need to make changes to support this?

som-snytt commented 2 years ago

I just fixed a Scala 2 incompatibility and was thinking partest could pre-process the dotty test corpus by letting dotty rewrite it to a compatible dialect first, then compile as normal. Maybe also process // error.

prolativ commented 2 years ago

@nicolasstucki I've just realized that your mechanism for pretty printing boxed compilation errors from external processes doesn't really work with check files (they would have to contain not only actual errors but also the frames and the comments we add to make debugging easier if the external error text was not parsed properly). Should we care about it? That wouldn't be a problem if we can assume we don't do any checks on compilation errors from older compilers.

nicolasstucki commented 2 years ago

The primary use case is to test that code compiled with the old compiler can be used in the new one. In this scenario the old compiler should not have errors and therefore there is not reason to worry about the check file.

When writing the test we might hit an error. If we do not see the error correctly it might be hard to know what happened. That was the reason I added this in the first place.

All other use cases came from the release flag.