Skip to content

Only enable experimental features for snapshot and nightly (V2) #11920

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

Merged
merged 17 commits into from
Mar 29, 2021

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Mar 28, 2021

Fixes #11774

Mostly based on #11852, but without the requirement that experimental features can only be used by tests in certain directories.

Also, errors are issued when an experimental import or setting is encountered, but the feature is not turned off in that case. It's good enough to have a single error in this case.

@odersky odersky added this to the 3.0.0-RC2 milestone Mar 28, 2021
@rjolly
Copy link
Contributor

rjolly commented Mar 28, 2021

What happens for community build?

@odersky
Copy link
Contributor Author

odersky commented Mar 28, 2021

Community build projects can be configured so that they only run for experimental versions of the compiler. E.g. see scodec.

@odersky
Copy link
Contributor Author

odersky commented Mar 28, 2021

Several community build projects would not compile under a stable main (this was also true for #11852, I believe). Aside from scodec, there are also: intent, scalap, scas, stdlib123. Also, there are downstream projects that could be affected. We need to decide what the policy should be. I see two choices:

  1. Allow CB projects to use experimental by default, and tests can opt into non-experimental with -Yno-experimental.
  2. Keep the standard policy (i.e. no experimental features in stable compiler), and don't run certain tests when run with an unstable compiler.

If it's (2), we need more work on the community build to adapt all the tests that would fail otherwise.

EDIT: It turns out (1) is not an option right now, since CommunityBuiltTests cannot see the dotc jar, so they cannot patch the variable.

Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

I was not sure about the mutable variable hack, but the new scheme looks reasonable.

@odersky
Copy link
Contributor Author

odersky commented Mar 28, 2021

Status after trying with simulating a non-snapshot compiler

  1. there's a failure for test-plugins, which might be spurious due to the way the test was setup.
  2. there are failures for community build doctest, because doctest would have to skip projects that use experimental features just like CB test does, but I don't know how to do that.

For DocTest: Look at dotty.communitybuild.projects.scala, value compilerSupportExperimental and how it is used in CommunityBuildTest. That logic needs to be duplicated (or shared if possible).

I am reverting here to the standard compiler, but I expect that at least the second problems will resurface once we go to a stable compiler. /cc @abgruszecki @romanowski

def checkExperimentalFeature(which: String, srcPos: SrcPos = NoSourcePosition)(using Context) =
def hasSpecialPermission =
new Exception().getStackTrace.exists(elem =>
assumeExperimentalIn.exists(elem.getClassName().startsWith(_)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that we can run the tests from a release compiler

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would we want to run tests on experimental features on a release compiler? These cannot be used and there will be a nightly that will cover those tests on that day anyway.

Copy link
Contributor Author

@odersky odersky Mar 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are there so that we can make sure that the compiler code base can in fact handle the experimental features. There's only one codebase. Those tests can be run from either release or experimental versions. The fact that compilers flag experimental imports as errors unless their version string is a nightly or snapshot is orthogonal to this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the previous workaround of experimental subdirectores has been reverted.

@odersky odersky merged commit cadf3bf into scala:master Mar 29, 2021
@odersky odersky deleted the fix-11774-v2 branch March 29, 2021 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle experimental features in releases
5 participants