-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Allow experimental language imports in experimental scopes #13396
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
aa2f544
Allow experimental language imports in experimental scopes
odersky e0ff162
Refactoring: move experimental imports checking to Checking.scala
odersky 00f77aa
Disregard synthetic definitions from experimental imports checks
odersky e2701f8
Also check definitions inside package objects
odersky 5891a73
Explain why enclosing scope is not experimental
odersky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
tests/neg-custom-args/no-experimental/experimental-erased.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import language.experimental.erasedDefinitions // error | ||
import annotation.experimental | ||
|
||
@experimental | ||
erased class CanThrow[-E <: Exception] | ||
|
||
def other = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,10 +25,4 @@ class Test2 { | |
|
||
class Test6 { | ||
import scala.language.experimental // ok | ||
} | ||
|
||
class Test7 { | ||
import scala.language.experimental | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deleted since we now check experimental imports after typer, and Test7 produces errors at Typer |
||
import experimental.genericNumberLiterals // error: no aliases can be used to refer to a language import | ||
val x: BigInt = 13232202002020202020202 // error | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import language.experimental.erasedDefinitions | ||
import annotation.experimental | ||
|
||
@experimental object Test: | ||
|
||
erased class CanThrow[-E <: Exception] | ||
|
||
def other = 1 | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import language.experimental.erasedDefinitions | ||
import annotation.experimental | ||
|
||
@experimental | ||
erased class CanThrow[-E <: Exception](val i: Int = 0) | ||
|
||
@experimental | ||
object Foo | ||
|
||
@experimental | ||
def bar = 1 | ||
|
||
|
||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To unblock #11721, this should not be an error. See dotty-staging@ea8cb80#diff-0ca71061afa8605808278d2aad85e45877447c09bc11be7c51d3a2e0ad35edc4R1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See
pos-curstomArgs/experimental.erased
for the same example that compiles. It's notCanThrow
that triggers the error butother
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested
pos-curstomArgs/experimental.erased
manually with-Yno-experimental
. I assume that will be tested anyway since we start with a stable compiler. Or do we need a separate pos test that asserts -Yno-experimental`?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is the same behavior as in master.
Compiles with snapshot build without error but fails when we add
-Yno-experimental
.If we cannot compile it with
-Yno-experimental
we will not be able to re-bootstrap on a stable compiler.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it manually with -
Yno-experimental
and verified that it compilesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be good to port this test https://github.com/lampepfl/dotty/pull/13394/files#diff-0ca71061afa8605808278d2aad85e45877447c09bc11be7c51d3a2e0ad35edc4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see what goes on. The generated package object is not experimental.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message of is also unhelpful. If a user does this change they will have no idea why it started failing.
import language.experimental.erasedDefinitions // error import annotation.experimental @experimental erased class CanThrow[-E <: Exception] + object Foo
The scope of
CanThrow
is still experimental. But now it it saysExperimental features may only be used with a nightly or snapshot version of the compiler
which has not changed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now disregard synthetic definitions in the check. That also takes care of compiler-generated companion objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe https://github.com/lampepfl/dotty/pull/13396/files#diff-53335a51b3630ff685db4a7f8b0e67d06bc74d3fb9c1d7e642a5e864ff240187R738 is the wrong way to generate the error message.