Skip to content

Allow import language.experimental.captureChecking in the REPL #16304

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
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/config/Feature.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ object Feature:
val pureFunctions = experimental("pureFunctions")
val captureChecking = experimental("captureChecking")

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

/** Is `feature` enabled by by a command-line setting? The enabling setting is
*
* -language:<prefix>feature
Expand Down
10 changes: 10 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import ast.untpd
import util.{NoSource, SimpleIdentityMap, SourceFile, HashSet, ReusableInstance}
import typer.{Implicits, ImportInfo, SearchHistory, SearchRoot, TypeAssigner, Typer, Nullables}
import inlines.Inliner
import ast.{tpd, untpd}
import config.Feature
import Nullables._
import Implicits.ContextualImplicits
import config.Settings._
Expand Down Expand Up @@ -648,6 +650,14 @@ object Contexts {
case Some(false) if ctx.settings.YexplicitNulls.value =>
setMode(this.mode | Mode.SafeNulls)
case _ =>

importInfo.qualifier match
case ref: untpd.RefTree =>
val prefix = ref.name.asTermName
for case untpd.ImportSelector(untpd.Ident(imported), untpd.EmptyTree, _) <- importInfo.selectors do
Feature.handleGlobalLanguageImport(prefix, imported)
case _ => ()

updateStore(importInfoLoc, importInfo)
def setTypeAssigner(typeAssigner: TypeAssigner): this.type = updateStore(typeAssignerLoc, typeAssigner)

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import scala.annotation.tailrec
import rewrites.Rewrites.{patch, overlapsPatch}
import reporting._
import config.Feature
import config.Feature.{sourceVersion, migrateTo3, globalOnlyImports}
import config.Feature.{sourceVersion, migrateTo3}
import config.SourceVersion._
import config.SourceVersion

Expand Down