Skip to content

Commit d774b40

Browse files
committed
Add scala.language.experimental.mode
1 parent 2a1a72c commit d774b40

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

compiler/src/dotty/tools/dotc/config/Feature.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ object Feature:
2323
private val genericNumberLiterals = experimental("genericNumberLiterals")
2424
val scala2macros = experimental("macros")
2525

26+
val mode = experimental("mode")
2627
val dependent = experimental("dependent")
2728
val erasedDefinitions = experimental("erasedDefinitions")
2829
val symbolLiterals = deprecated("symbolLiterals")
@@ -37,6 +38,7 @@ object Feature:
3738
// TODO compute this list
3839
// TODO remove features that do not enable experimental mode
3940
val experimentalAutoEnableFeatures: List[TermName] = List(
41+
mode,
4042
namedTypeArguments,
4143
genericNumberLiterals,
4244
erasedDefinitions,

library/src/scala/runtime/stdLibPatches/language.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ object language:
2020
*/
2121
object experimental:
2222

23+
/** Enable use of experimental APIs by making the current scope an experimental one.
24+
*
25+
* @see [[https://dotty.epfl.ch/docs/reference/other-new-features/experimental-defs]]
26+
*/
27+
@compileTimeOnly("`mode` can only be used at compile time in import statements")
28+
object mode
29+
30+
2331
/* Experimental support for richer dependent types (disabled for now)
2432
* One can still run the compiler with support for parsing singleton applications
2533
* using command line option `-language:experimental.dependent`.

project/MiMaFilters.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ object MiMaFilters {
88
val ForwardsBreakingChanges: Map[String, Seq[ProblemFilter]] = Map(
99
// Additions that require a new minor version of the library
1010
Build.previousDottyVersion -> Seq(
11+
ProblemFilters.exclude[MissingFieldProblem]("scala.runtime.stdLibPatches.language#experimental.mode"),
12+
ProblemFilters.exclude[MissingClassProblem]("scala.runtime.stdLibPatches.language$experimental$mode$"),
1113
),
1214

1315
// Additions since last LTS

tests/pos/experimental-mode.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//> using option -Yno-experimental
2+
3+
import scala.language.experimental.mode
4+
import scala.annotation.experimental
5+
6+
@experimental
7+
def foo = 1
8+
9+
def bar = foo // made `@experimental` by `scala.language.experimental.mode`

0 commit comments

Comments
 (0)