Skip to content

Commit 5b46900

Browse files
authored
Merge pull request #11355 from dotty-staging/change-future-source
Change 3.1 to future
2 parents a4f009d + bcaac78 commit 5b46900

35 files changed

+84
-75
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ object desugar {
226226

227227
def desugarContextBounds(rhs: Tree): Tree = rhs match
228228
case ContextBounds(tbounds, cxbounds) =>
229-
val iflag = if sourceVersion.isAtLeast(`3.1`) then Given else Implicit
229+
val iflag = if sourceVersion.isAtLeast(`future`) then Given else Implicit
230230
evidenceParamBuf ++= makeImplicitParameters(
231231
cxbounds, iflag, forPrimaryConstructor = isPrimaryConstructor)
232232
tbounds

compiler/src/dotty/tools/dotc/ast/untpd.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
169169
enum GenCheckMode {
170170
case Ignore // neither filter nor check since filtering was done before
171171
case Check // check that pattern is irrefutable
172-
case FilterNow // filter out non-matching elements since we are not yet in 3.1
172+
case FilterNow // filter out non-matching elements since we are not yet in 3.x
173173
case FilterAlways // filter out non-matching elements since pattern is prefixed by `case`
174174
}
175175

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
9595
val feature: Setting[Boolean] = BooleanSetting("-feature", "Emit warning and location for usages of features that should be imported explicitly.", aliases = List("--feature"))
9696
val help: Setting[Boolean] = BooleanSetting("-help", "Print a synopsis of standard options.", aliases = List("--help"))
9797
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"))
98-
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"))
98+
val source: Setting[String] = ChoiceSetting("-source", "source version", "source version", List("3.0", "future", "3.0-migration", "future-migration"), "3.0", aliases = List("--source"))
9999
val scalajs: Setting[Boolean] = BooleanSetting("-scalajs", "Compile in Scala.js mode (requires scalajs-library.jar on the classpath).", aliases = List("--scalajs"))
100100
val unchecked: Setting[Boolean] = BooleanSetting("-unchecked", "Enable additional warnings where generated code depends on assumptions.", aliases = List("--unchecked"))
101101
val uniqid: Setting[Boolean] = BooleanSetting("-uniqid", "Uniquely tag all identifiers in debugging output.", aliases = List("--unique-id"))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import core.Decorators.{_, given}
99
import util.Property
1010

1111
enum SourceVersion:
12-
case `3.0-migration`, `3.0`, `3.1-migration`, `3.1`
12+
case `3.0-migration`, `3.0`, `future-migration`, `future`
1313

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

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Contexts._, Types._, Symbols._, Names._, Flags._
66
import Denotations.SingleDenotation
77
import Decorators._
88
import collection.mutable
9-
import config.SourceVersion.`3.1`
9+
import config.SourceVersion.future
1010
import config.Feature.sourceVersion
1111

1212
/** Realizability status */
@@ -202,8 +202,8 @@ class CheckRealizable(using Context) {
202202
realizability(fld.info).mapError(r => new HasProblemField(fld, r))
203203
}
204204
}
205-
if sourceVersion.isAtLeast(`3.1`) then
206-
// check fields only from version 3.1.
205+
if sourceVersion.isAtLeast(future) then
206+
// check fields only from version 3.x.
207207
// Reason: An embedded field could well be nullable, which means it
208208
// should not be part of a path and need not be checked; but we cannot recognize
209209
// this situation until we have a typesystem that tracks nullability.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ object SymDenotations {
946946
is(Macro, butNot = Inline) && is(Erased)
947947
// Consider the macros of StringContext as plain Scala 2 macros when
948948
// compiling the standard library with Dotty.
949-
// This should be removed on Scala 3.1
949+
// This should be removed on Scala 3.x
950950
&& owner.ne(defn.StringContextClass)
951951

952952
/** An erased value or an erased inline method or field */

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,7 @@ object Parsers {
15631563
if in.token == LBRACE || in.token == INDENT then
15641564
t
15651565
else
1566-
if sourceVersion.isAtLeast(`3.1`) then
1566+
if sourceVersion.isAtLeast(future) then
15671567
deprecationWarning(DeprecatedWithOperator(), withOffset)
15681568
atSpan(startOffset(t)) { makeAndType(t, withType()) }
15691569
else t
@@ -1613,7 +1613,7 @@ object Parsers {
16131613
if isSimpleLiteral then
16141614
SingletonTypeTree(simpleLiteral())
16151615
else if in.token == USCORE then
1616-
if sourceVersion.isAtLeast(`3.1`) then
1616+
if sourceVersion.isAtLeast(future) then
16171617
deprecationWarning(em"`_` is deprecated for wildcard arguments of types: use `?` instead")
16181618
patch(source, Span(in.offset, in.offset + 1), "?")
16191619
val start = in.skipToken()
@@ -2080,11 +2080,11 @@ object Parsers {
20802080
val isVarargSplice = location.inArgs && followingIsVararg()
20812081
in.nextToken()
20822082
if isVarargSplice then
2083-
if sourceVersion.isAtLeast(`3.1`) then
2083+
if sourceVersion.isAtLeast(future) then
20842084
report.errorOrMigrationWarning(
2085-
em"The syntax `x: _*` is no longer supported for vararg splices; use `x*` instead${rewriteNotice("3.1")}",
2085+
em"The syntax `x: _*` is no longer supported for vararg splices; use `x*` instead${rewriteNotice("future")}",
20862086
in.sourcePos(uscoreStart))
2087-
if sourceVersion == `3.1-migration` then
2087+
if sourceVersion == `future-migration` then
20882088
patch(source, Span(t.span.end, in.lastOffset), " *")
20892089
else if opStack.nonEmpty then
20902090
report.errorOrMigrationWarning(
@@ -2158,15 +2158,15 @@ object Parsers {
21582158
val name = bindingName()
21592159
val t =
21602160
if (in.token == COLON && location == Location.InBlock) {
2161-
if sourceVersion.isAtLeast(`3.1`) then
2161+
if sourceVersion.isAtLeast(future) then
21622162
// Don't error in non-strict mode, as the alternative syntax "implicit (x: T) => ... "
21632163
// is not supported by Scala2.x
21642164
report.errorOrMigrationWarning(
2165-
s"This syntax is no longer supported; parameter needs to be enclosed in (...)${rewriteNotice("3.1")}",
2165+
s"This syntax is no longer supported; parameter needs to be enclosed in (...)${rewriteNotice("future")}",
21662166
source.atSpan(Span(start, in.lastOffset)))
21672167
in.nextToken()
21682168
val t = infixType()
2169-
if (sourceVersion == `3.1-migration`) {
2169+
if (sourceVersion == `future-migration`) {
21702170
patch(source, Span(start), "(")
21712171
patch(source, Span(in.lastOffset), ")")
21722172
}
@@ -2482,7 +2482,7 @@ object Parsers {
24822482
atSpan(startOffset(pat), accept(LARROW)) {
24832483
val checkMode =
24842484
if (casePat) GenCheckMode.FilterAlways
2485-
else if sourceVersion.isAtLeast(`3.1`) then GenCheckMode.Check
2485+
else if sourceVersion.isAtLeast(future) then GenCheckMode.Check
24862486
else GenCheckMode.FilterNow // filter for now, to keep backwards compat
24872487
GenFrom(pat, subExpr(), checkMode)
24882488
}
@@ -2655,7 +2655,7 @@ object Parsers {
26552655
p
26562656

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

31123112
/** ‘*' | ‘_' */
31133113
def wildcardSelector() =
3114-
if in.token == USCORE && sourceVersion.isAtLeast(`3.1`) then
3114+
if in.token == USCORE && sourceVersion.isAtLeast(future) then
31153115
report.errorOrMigrationWarning(
31163116
em"`_` is no longer supported for a wildcard import; use `*` instead${rewriteNotice("3.1")}",
31173117
in.sourcePos())
@@ -3129,7 +3129,7 @@ object Parsers {
31293129
/** id [‘as’ (id | ‘_’) */
31303130
def namedSelector(from: Ident) =
31313131
if in.token == ARROW || isIdent(nme.as) then
3132-
if in.token == ARROW && sourceVersion.isAtLeast(`3.1`) then
3132+
if in.token == ARROW && sourceVersion.isAtLeast(future) then
31333133
report.errorOrMigrationWarning(
31343134
em"The import renaming `a => b` is no longer supported ; use `a as b` instead${rewriteNotice("3.1")}",
31353135
in.sourcePos())
@@ -3226,7 +3226,7 @@ object Parsers {
32263226
/** PatDef ::= ids [‘:’ Type] ‘=’ Expr
32273227
* | Pattern2 [‘:’ Type] ‘=’ Expr
32283228
* VarDef ::= PatDef
3229-
* | id {`,' id} `:' Type `=' `_' (deprecated in 3.1)
3229+
* | id {`,' id} `:' Type `=' `_' (deprecated in 3.x)
32303230
* ValDcl ::= id {`,' id} `:' Type
32313231
* VarDcl ::= id {`,' id} `:' Type
32323232
*/
@@ -3253,7 +3253,7 @@ object Parsers {
32533253
subExpr() match
32543254
case rhs0 @ Ident(name) if placeholderParams.nonEmpty && name == placeholderParams.head.name
32553255
&& !tpt.isEmpty && mods.is(Mutable) && lhs.forall(_.isInstanceOf[Ident]) =>
3256-
if sourceVersion.isAtLeast(`3.1`) then
3256+
if sourceVersion.isAtLeast(future) then
32573257
deprecationWarning(
32583258
em"""`= _` has been deprecated; use `= uninitialized` instead.
32593259
|`uninitialized` can be imported with `scala.compiletime.uninitialized`.""", rhsOffset)

compiler/src/dotty/tools/dotc/transform/NonLocalReturns.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class NonLocalReturns extends MiniPhase {
8989

9090
override def transformReturn(tree: Return)(using Context): Tree =
9191
if isNonLocalReturn(tree) then
92-
if sourceVersion.isAtLeast(`3.1`) then
92+
if sourceVersion.isAtLeast(future) then
9393
report.errorOrMigrationWarning("Non local returns are no longer supported; use scala.util.control.NonLocalReturns instead", tree.srcPos)
9494
nonLocalReturnThrow(tree.expr, tree.from.symbol).withSpan(tree.span)
9595
else tree

compiler/src/dotty/tools/dotc/transform/PostTyper.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
159159
if sym.isScala2Macro && !ctx.settings.XignoreScala2Macros.value then
160160
if !sym.owner.unforcedDecls.exists(p => !p.isScala2Macro && p.name == sym.name && p.signature == sym.signature)
161161
// Allow scala.reflect.materializeClassTag to be able to compile scala/reflect/package.scala
162-
// This should be removed on Scala 3.1
162+
// This should be removed on Scala 3.x
163163
&& sym.owner != defn.ReflectPackageClass
164164
then
165165
report.error("No Scala 3 implementation found for this Scala 2 macro.", tree.srcPos)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ trait Checking {
700700
def check(pat: Tree, pt: Type): Boolean = (pt <:< pat.tpe) || fail(pat, pt)
701701

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

12671267
def checkMatchable(tp: Type, pos: SrcPos, pattern: Boolean)(using Context): Unit =
1268-
if !tp.derivesFrom(defn.MatchableClass) && sourceVersion.isAtLeast(`3.1-migration`) then
1268+
if !tp.derivesFrom(defn.MatchableClass) && sourceVersion.isAtLeast(`future-migration`) then
12691269
val kind = if pattern then "pattern selector" else "value"
12701270
report.warning(
12711271
em"""${kind} should be an instance of Matchable,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@ class Namer { typer: Typer =>
12271227
else if pclazz.isEffectivelySealed && pclazz.associatedFile != cls.associatedFile then
12281228
if pclazz.is(Sealed) then
12291229
report.error(UnableToExtendSealedClass(pclazz), cls.srcPos)
1230-
else if sourceVersion.isAtLeast(`3.1`) then
1230+
else if sourceVersion.isAtLeast(future) then
12311231
checkFeature(nme.adhocExtensions,
12321232
i"Unless $pclazz is declared 'open', its extension in a separate file",
12331233
cls.topLevelClass,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ trait QuotesAndSplices {
6161
typedQuotePattern(tree, pt, qctx)
6262
else if tree.quoted.isType then
6363
val msg = em"Consider using canonical type constructor scala.quoted.Type.of[${tree.quoted}] instead"
64-
if sourceVersion.isAtLeast(`3.1-migration`) then report.error(msg, tree.srcPos)
64+
if sourceVersion.isAtLeast(`future-migration`) then report.error(msg, tree.srcPos)
6565
else report.warning(msg, tree.srcPos)
6666
typedTypeApply(untpd.TypeApply(untpd.ref(defn.QuotedTypeModule_of.termRef), tree.quoted :: Nil), pt)(using quoteContext).select(nme.apply).appliedTo(qctx)
6767
else
@@ -166,7 +166,7 @@ trait QuotesAndSplices {
166166
else
167167
val tree1 = typedSelect(untpd.Select(tree.expr, tpnme.Underlying), pt)(using spliceContext).withSpan(tree.span)
168168
val msg = em"Consider using canonical type reference ${tree1.tpe} instead"
169-
if sourceVersion.isAtLeast(`3.1-migration`) then report.error(msg, tree.srcPos)
169+
if sourceVersion.isAtLeast(`future-migration`) then report.error(msg, tree.srcPos)
170170
else report.warning(msg, tree.srcPos)
171171
tree1
172172
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ class Typer extends Namer
848848
val tag = withTag(defn.TypeTestClass.typeRef.appliedTo(pt, tref))
849849
.orElse(withTag(defn.ClassTagClass.typeRef.appliedTo(tref)))
850850
.getOrElse(tree)
851-
if tag.symbol.owner == defn.ClassTagClass && config.Feature.sourceVersion.isAtLeast(config.SourceVersion.`3.1`) then
851+
if tag.symbol.owner == defn.ClassTagClass && config.Feature.sourceVersion.isAtLeast(config.SourceVersion.future) then
852852
report.warning("Use of `scala.reflect.ClassTag` for type testing may be unsound. Consider using `scala.reflect.TypeTest` instead.", tree.srcPos)
853853
tag
854854
case _ => tree
@@ -1442,7 +1442,7 @@ class Typer extends Namer
14421442
tree.selector.removeAttachment(desugar.CheckIrrefutable) match {
14431443
case Some(checkMode) =>
14441444
val isPatDef = checkMode == desugar.MatchCheck.IrrefutablePatDef
1445-
if (!checkIrrefutable(sel, pat, isPatDef) && sourceVersion == `3.1-migration`)
1445+
if (!checkIrrefutable(sel, pat, isPatDef) && sourceVersion == `future-migration`)
14461446
if (isPatDef) patch(Span(tree.selector.span.end), ": @unchecked")
14471447
else patch(Span(pat.span.start), "case ")
14481448

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

0 commit comments

Comments
 (0)