Skip to content

Commit 54c5be7

Browse files
committed
wip
1 parent f7f1b6b commit 54c5be7

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ object Feature:
3636

3737
def experimentalAutoEnableFeatures(using Context): List[TermName] =
3838
defn.languageExperimentalFeatures
39-
.map(sym => experimental(sym.name.asTermName))
39+
.map(sym => experimental(sym.name))
4040
.filterNot(_ == captureChecking) // TODO is this correct?
4141

4242
val globalOnlyImports: Set[TermName] = Set(pureFunctions, captureChecking)

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,8 +2013,12 @@ class Definitions {
20132013
CapabilityAnnot, RequiresCapabilityAnnot,
20142014
RetainsAnnot, RetainsCapAnnot, RetainsByNameAnnot)
20152015

2016-
@tu lazy val languageExperimentalFeatures: List[Symbol] =
2017-
LanguageExperimentalModule.moduleClass.info.decls.toList.filter(_.isAllOf(Lazy | Module))
2016+
/** Experimental language fetures defined in `scala.runtime.stdLibPatches.language.experimental`.
2017+
*
2018+
* This list does not incluede `scala.language.experimental.macros`.
2019+
*/
2020+
@tu lazy val languageExperimentalFeatures: List[TermSymbol] =
2021+
LanguageExperimentalModule.moduleClass.info.decls.toList.filter(_.isAllOf(Lazy | Module)).map(_.asTerm)
20182022

20192023
// ----- primitive value class machinery ------------------------------------------
20202024

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -833,9 +833,6 @@ object Checking {
833833
languageImport(qual) match
834834
case Some(nme.experimental)
835835
if !ctx.owner.isInExperimentalScope && !selectors.forall(isAllowedImport) =>
836-
def check(stable: => String) =
837-
Feature.checkExperimentalFeature("features", imp.srcPos,
838-
s"\n\nNote: the scope enclosing the import is not considered experimental because it contains the\nnon-experimental $stable")
839836
if ctx.owner.is(Package) || ctx.owner.name.startsWith(str.REPL_SESSION_LINE) then
840837
// mark all top-level definitions as @experimental
841838
for tree <- nonExperimentalStats(trees) do
@@ -846,7 +843,8 @@ object Checking {
846843
if !sym.isExperimental then
847844
sym.addAnnotation(Annotations.Annotation(defn.ExperimentalAnnot, sym.span))
848845
case tree =>
849-
check(i"expression ${tree}")
846+
// There is no definition to attach the @experimental annotation
847+
report.error("Implementation restriction: top-level `val _ = ...` is not supported with experimental language imports.", tree.srcPos)
850848
else Feature.checkExperimentalFeature("feature local import", imp.srcPos)
851849
case _ =>
852850
end checkExperimentalImports

tests/pos-custom-args/captures/curried-closures.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//> using options -experimental
2+
13
object Test:
24
def map2(xs: List[Int])(f: Int => Int): List[Int] = xs.map(f)
35
val f1 = map2

tests/pos-custom-args/captures/try.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def handle[E <: Exception, R](op: (erased CanThrow[E]) -> R)(handler: E -> R): R
1818
try op(x)
1919
catch case ex: E => handler(ex)
2020

21-
val _ = handle { (erased x) =>
21+
val bar = handle { (erased x) =>
2222
if true then
2323
raise(new Exception)(using x)
2424
22

0 commit comments

Comments
 (0)