Skip to content
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

Change 3.1 to future #11355

Merged
merged 4 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ object desugar {

def desugarContextBounds(rhs: Tree): Tree = rhs match
case ContextBounds(tbounds, cxbounds) =>
val iflag = if sourceVersion.isAtLeast(`3.1`) then Given else Implicit
val iflag = if sourceVersion.isAtLeast(`future`) then Given else Implicit
evidenceParamBuf ++= makeImplicitParameters(
cxbounds, iflag, forPrimaryConstructor = isPrimaryConstructor)
tbounds
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/untpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
enum GenCheckMode {
case Ignore // neither filter nor check since filtering was done before
case Check // check that pattern is irrefutable
case FilterNow // filter out non-matching elements since we are not yet in 3.1
case FilterNow // filter out non-matching elements since we are not yet in 3.x
case FilterAlways // filter out non-matching elements since pattern is prefixed by `case`
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
val feature: Setting[Boolean] = BooleanSetting("-feature", "Emit warning and location for usages of features that should be imported explicitly.", aliases = List("--feature"))
val help: Setting[Boolean] = BooleanSetting("-help", "Print a synopsis of standard options.", aliases = List("--help"))
val release: Setting[String] = ChoiceSetting("-release", "release", "Compile code with classes specific to the given version of the Java platform available on the classpath and emit bytecode for this version.", supportedReleaseVersions, "", aliases = List("--release"))
val source: Setting[String] = ChoiceSetting("-source", "source version", "source version", List("3.0", "3.1", "3.0-migration", "3.1-migration"), "3.0", aliases = List("--source"))
val source: Setting[String] = ChoiceSetting("-source", "source version", "source version", List("3.0", "future", "3.0-migration", "future-migration"), "3.0", aliases = List("--source"))
val scalajs: Setting[Boolean] = BooleanSetting("-scalajs", "Compile in Scala.js mode (requires scalajs-library.jar on the classpath).", aliases = List("--scalajs"))
val unchecked: Setting[Boolean] = BooleanSetting("-unchecked", "Enable additional warnings where generated code depends on assumptions.", aliases = List("--unchecked"))
val uniqid: Setting[Boolean] = BooleanSetting("-uniqid", "Uniquely tag all identifiers in debugging output.", aliases = List("--unique-id"))
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/SourceVersion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import core.Decorators.{_, given}
import util.Property

enum SourceVersion:
case `3.0-migration`, `3.0`, `3.1-migration`, `3.1`
case `3.0-migration`, `3.0`, `future-migration`, `future`

val isMigrating: Boolean = toString.endsWith("-migration")

Expand Down
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/core/CheckRealizable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Contexts._, Types._, Symbols._, Names._, Flags._
import Denotations.SingleDenotation
import Decorators._
import collection.mutable
import config.SourceVersion.`3.1`
import config.SourceVersion.future
import config.Feature.sourceVersion

/** Realizability status */
Expand Down Expand Up @@ -202,8 +202,8 @@ class CheckRealizable(using Context) {
realizability(fld.info).mapError(r => new HasProblemField(fld, r))
}
}
if sourceVersion.isAtLeast(`3.1`) then
// check fields only from version 3.1.
if sourceVersion.isAtLeast(future) then
// check fields only from version 3.x.
// Reason: An embedded field could well be nullable, which means it
// should not be part of a path and need not be checked; but we cannot recognize
// this situation until we have a typesystem that tracks nullability.
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ object SymDenotations {
is(Macro, butNot = Inline) && is(Erased)
// Consider the macros of StringContext as plain Scala 2 macros when
// compiling the standard library with Dotty.
// This should be removed on Scala 3.1
// This should be removed on Scala 3.x
&& owner.ne(defn.StringContextClass)

/** An erased value or an erased inline method or field */
Expand Down
32 changes: 16 additions & 16 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ object Parsers {
if in.token == LBRACE || in.token == INDENT then
t
else
if sourceVersion.isAtLeast(`3.1`) then
if sourceVersion.isAtLeast(future) then
deprecationWarning(DeprecatedWithOperator(), withOffset)
atSpan(startOffset(t)) { makeAndType(t, withType()) }
else t
Expand Down Expand Up @@ -1613,7 +1613,7 @@ object Parsers {
if isSimpleLiteral then
SingletonTypeTree(simpleLiteral())
else if in.token == USCORE then
if sourceVersion.isAtLeast(`3.1`) then
if sourceVersion.isAtLeast(future) then
deprecationWarning(em"`_` is deprecated for wildcard arguments of types: use `?` instead")
patch(source, Span(in.offset, in.offset + 1), "?")
val start = in.skipToken()
Expand Down Expand Up @@ -2080,11 +2080,11 @@ object Parsers {
val isVarargSplice = location.inArgs && followingIsVararg()
in.nextToken()
if isVarargSplice then
if sourceVersion.isAtLeast(`3.1`) then
if sourceVersion.isAtLeast(future) then
report.errorOrMigrationWarning(
em"The syntax `x: _*` is no longer supported for vararg splices; use `x*` instead${rewriteNotice("3.1")}",
em"The syntax `x: _*` is no longer supported for vararg splices; use `x*` instead${rewriteNotice("future")}",
in.sourcePos(uscoreStart))
if sourceVersion == `3.1-migration` then
if sourceVersion == `future-migration` then
patch(source, Span(t.span.end, in.lastOffset), " *")
else if opStack.nonEmpty then
report.errorOrMigrationWarning(
Expand Down Expand Up @@ -2158,15 +2158,15 @@ object Parsers {
val name = bindingName()
val t =
if (in.token == COLON && location == Location.InBlock) {
if sourceVersion.isAtLeast(`3.1`) then
if sourceVersion.isAtLeast(future) then
// Don't error in non-strict mode, as the alternative syntax "implicit (x: T) => ... "
// is not supported by Scala2.x
report.errorOrMigrationWarning(
s"This syntax is no longer supported; parameter needs to be enclosed in (...)${rewriteNotice("3.1")}",
s"This syntax is no longer supported; parameter needs to be enclosed in (...)${rewriteNotice("future")}",
source.atSpan(Span(start, in.lastOffset)))
in.nextToken()
val t = infixType()
if (sourceVersion == `3.1-migration`) {
if (sourceVersion == `future-migration`) {
patch(source, Span(start), "(")
patch(source, Span(in.lastOffset), ")")
}
Expand Down Expand Up @@ -2482,7 +2482,7 @@ object Parsers {
atSpan(startOffset(pat), accept(LARROW)) {
val checkMode =
if (casePat) GenCheckMode.FilterAlways
else if sourceVersion.isAtLeast(`3.1`) then GenCheckMode.Check
else if sourceVersion.isAtLeast(future) then GenCheckMode.Check
else GenCheckMode.FilterNow // filter for now, to keep backwards compat
GenFrom(pat, subExpr(), checkMode)
}
Expand Down Expand Up @@ -2655,7 +2655,7 @@ object Parsers {
p

private def warnStarMigration(p: Tree) =
if sourceVersion.isAtLeast(`3.1`) then
if sourceVersion.isAtLeast(future) then
report.errorOrMigrationWarning(
em"The syntax `x: _*` is no longer supported for vararg splices; use `x*` instead",
in.sourcePos(startOffset(p)))
Expand Down Expand Up @@ -2790,8 +2790,8 @@ object Parsers {
syntaxError(DuplicatePrivateProtectedQualifier())
inBrackets {
if in.token == THIS then
if sourceVersion.isAtLeast(`3.1`) then
deprecationWarning("The [this] qualifier is deprecated in Scala 3.1; it should be dropped.")
if sourceVersion.isAtLeast(future) then
deprecationWarning("The [this] qualifier will be deprecated in the future; it should be dropped.")
in.nextToken()
mods | Local
else mods.withPrivateWithin(ident().toTypeName)
Expand Down Expand Up @@ -3111,7 +3111,7 @@ object Parsers {

/** ‘*' | ‘_' */
def wildcardSelector() =
if in.token == USCORE && sourceVersion.isAtLeast(`3.1`) then
if in.token == USCORE && sourceVersion.isAtLeast(future) then
report.errorOrMigrationWarning(
em"`_` is no longer supported for a wildcard import; use `*` instead${rewriteNotice("3.1")}",
in.sourcePos())
Expand All @@ -3129,7 +3129,7 @@ object Parsers {
/** id [‘as’ (id | ‘_’) */
def namedSelector(from: Ident) =
if in.token == ARROW || isIdent(nme.as) then
if in.token == ARROW && sourceVersion.isAtLeast(`3.1`) then
if in.token == ARROW && sourceVersion.isAtLeast(future) then
report.errorOrMigrationWarning(
em"The import renaming `a => b` is no longer supported ; use `a as b` instead${rewriteNotice("3.1")}",
in.sourcePos())
Expand Down Expand Up @@ -3226,7 +3226,7 @@ object Parsers {
/** PatDef ::= ids [‘:’ Type] ‘=’ Expr
* | Pattern2 [‘:’ Type] ‘=’ Expr
* VarDef ::= PatDef
* | id {`,' id} `:' Type `=' `_' (deprecated in 3.1)
* | id {`,' id} `:' Type `=' `_' (deprecated in 3.x)
* ValDcl ::= id {`,' id} `:' Type
* VarDcl ::= id {`,' id} `:' Type
*/
Expand All @@ -3253,7 +3253,7 @@ object Parsers {
subExpr() match
case rhs0 @ Ident(name) if placeholderParams.nonEmpty && name == placeholderParams.head.name
&& !tpt.isEmpty && mods.is(Mutable) && lhs.forall(_.isInstanceOf[Ident]) =>
if sourceVersion.isAtLeast(`3.1`) then
if sourceVersion.isAtLeast(future) then
deprecationWarning(
em"""`= _` has been deprecated; use `= uninitialized` instead.
|`uninitialized` can be imported with `scala.compiletime.uninitialized`.""", rhsOffset)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class NonLocalReturns extends MiniPhase {

override def transformReturn(tree: Return)(using Context): Tree =
if isNonLocalReturn(tree) then
if sourceVersion.isAtLeast(`3.1`) then
if sourceVersion.isAtLeast(future) then
report.errorOrMigrationWarning("Non local returns are no longer supported; use scala.util.control.NonLocalReturns instead", tree.srcPos)
nonLocalReturnThrow(tree.expr, tree.from.symbol).withSpan(tree.span)
else tree
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/PostTyper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
if sym.isScala2Macro && !ctx.settings.XignoreScala2Macros.value then
if !sym.owner.unforcedDecls.exists(p => !p.isScala2Macro && p.name == sym.name && p.signature == sym.signature)
// Allow scala.reflect.materializeClassTag to be able to compile scala/reflect/package.scala
// This should be removed on Scala 3.1
// This should be removed on Scala 3.x
&& sym.owner != defn.ReflectPackageClass
then
report.error("No Scala 3 implementation found for this Scala 2 macro.", tree.srcPos)
Expand Down
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ trait Checking {
def check(pat: Tree, pt: Type): Boolean = (pt <:< pat.tpe) || fail(pat, pt)

def recur(pat: Tree, pt: Type): Boolean =
!sourceVersion.isAtLeast(`3.1`) || // only for 3.1 for now since mitigations work only after this PR
!sourceVersion.isAtLeast(future) || // only for 3.x for now since mitigations work only after this PR
pt.hasAnnotation(defn.UncheckedAnnot) || {
patmatch.println(i"check irrefutable $pat: ${pat.tpe} against $pt")
pat match {
Expand Down Expand Up @@ -844,7 +844,7 @@ trait Checking {
!meth.isDeclaredInfix &&
!meth.maybeOwner.is(Scala2x) &&
!infixOKSinceFollowedBy(tree.right) &&
sourceVersion.isAtLeast(`3.1`) =>
sourceVersion.isAtLeast(future) =>
val (kind, alternative) =
if (ctx.mode.is(Mode.Type))
("type", (n: Name) => s"prefix syntax $n[...]")
Expand Down Expand Up @@ -1265,7 +1265,7 @@ trait Checking {
if stat.isDef then seen += tname

def checkMatchable(tp: Type, pos: SrcPos, pattern: Boolean)(using Context): Unit =
if !tp.derivesFrom(defn.MatchableClass) && sourceVersion.isAtLeast(`3.1-migration`) then
if !tp.derivesFrom(defn.MatchableClass) && sourceVersion.isAtLeast(`future-migration`) then
val kind = if pattern then "pattern selector" else "value"
report.warning(
em"""${kind} should be an instance of Matchable,
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,7 @@ class Namer { typer: Typer =>
else if pclazz.isEffectivelySealed && pclazz.associatedFile != cls.associatedFile then
if pclazz.is(Sealed) then
report.error(UnableToExtendSealedClass(pclazz), cls.srcPos)
else if sourceVersion.isAtLeast(`3.1`) then
else if sourceVersion.isAtLeast(future) then
checkFeature(nme.adhocExtensions,
i"Unless $pclazz is declared 'open', its extension in a separate file",
cls.topLevelClass,
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ trait QuotesAndSplices {
typedQuotePattern(tree, pt, qctx)
else if tree.quoted.isType then
val msg = em"Consider using canonical type constructor scala.quoted.Type.of[${tree.quoted}] instead"
if sourceVersion.isAtLeast(`3.1-migration`) then report.error(msg, tree.srcPos)
if sourceVersion.isAtLeast(`future-migration`) then report.error(msg, tree.srcPos)
else report.warning(msg, tree.srcPos)
typedTypeApply(untpd.TypeApply(untpd.ref(defn.QuotedTypeModule_of.termRef), tree.quoted :: Nil), pt)(using quoteContext).select(nme.apply).appliedTo(qctx)
else
Expand Down Expand Up @@ -166,7 +166,7 @@ trait QuotesAndSplices {
else
val tree1 = typedSelect(untpd.Select(tree.expr, tpnme.Underlying), pt)(using spliceContext).withSpan(tree.span)
val msg = em"Consider using canonical type reference ${tree1.tpe} instead"
if sourceVersion.isAtLeast(`3.1-migration`) then report.error(msg, tree.srcPos)
if sourceVersion.isAtLeast(`future-migration`) then report.error(msg, tree.srcPos)
else report.warning(msg, tree.srcPos)
tree1
}
Expand Down
12 changes: 6 additions & 6 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ class Typer extends Namer
val tag = withTag(defn.TypeTestClass.typeRef.appliedTo(pt, tref))
.orElse(withTag(defn.ClassTagClass.typeRef.appliedTo(tref)))
.getOrElse(tree)
if tag.symbol.owner == defn.ClassTagClass && config.Feature.sourceVersion.isAtLeast(config.SourceVersion.`3.1`) then
if tag.symbol.owner == defn.ClassTagClass && config.Feature.sourceVersion.isAtLeast(config.SourceVersion.future) then
report.warning("Use of `scala.reflect.ClassTag` for type testing may be unsound. Consider using `scala.reflect.TypeTest` instead.", tree.srcPos)
tag
case _ => tree
Expand Down Expand Up @@ -1442,7 +1442,7 @@ class Typer extends Namer
tree.selector.removeAttachment(desugar.CheckIrrefutable) match {
case Some(checkMode) =>
val isPatDef = checkMode == desugar.MatchCheck.IrrefutablePatDef
if (!checkIrrefutable(sel, pat, isPatDef) && sourceVersion == `3.1-migration`)
if (!checkIrrefutable(sel, pat, isPatDef) && sourceVersion == `future-migration`)
if (isPatDef) patch(Span(tree.selector.span.end), ": @unchecked")
else patch(Span(pat.span.start), "case ")

Expand Down Expand Up @@ -2444,7 +2444,7 @@ class Typer extends Namer
}
}
nestedCtx.typerState.commit()
if sourceVersion.isAtLeast(`3.1`) then
if sourceVersion.isAtLeast(future) then
lazy val (prefix, suffix) = res match {
case Block(mdef @ DefDef(_, vparams :: Nil, _, _) :: Nil, _: Closure) =>
val arity = vparams.length
Expand All @@ -2456,7 +2456,7 @@ class Typer extends Namer
if ((prefix ++ suffix).isEmpty) "simply leave out the trailing ` _`"
else s"use `$prefix<function>$suffix` instead"
report.errorOrMigrationWarning(i"""The syntax `<function> _` is no longer supported;
|you can $remedy""", tree.srcPos, `3.1`)
|you can $remedy""", tree.srcPos, future)
if sourceVersion.isMigrating then
patch(Span(tree.span.start), prefix)
patch(Span(qual.span.end, tree.span.end), suffix)
Expand Down Expand Up @@ -3164,8 +3164,8 @@ class Typer extends Namer
def isContextBoundParams = wtp.stripPoly match
case MethodType(EvidenceParamName(_) :: _) => true
case _ => false
if sourceVersion == `3.1-migration` && isContextBoundParams
then // Under 3.1-migration, don't infer implicit arguments yet for parameters
if sourceVersion == `future-migration` && isContextBoundParams
then // Under future-migration, don't infer implicit arguments yet for parameters
// coming from context bounds. Issue a warning instead and offer a patch.
report.migrationWarning(
em"""Context bounds will map to context parameters.
Expand Down
Loading