Skip to content

Commit e5abec0

Browse files
authored
Merge pull request #14294 from griggt/stricter-pattern-bindings-3.2
Enable stricter pattern binding warnings by default
2 parents 3432dbf + e29c40f commit e5abec0

File tree

120 files changed

+459
-419
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+459
-419
lines changed

compiler/src/dotty/tools/backend/jvm/BCodeBodyBuilder.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
359359
// but I was able to derrive it by reading
360360
// AbstractValidatingLambdaMetafactory.validateMetafactoryArgs
361361

362-
val DesugaredSelect(prefix, _) = fun
362+
val DesugaredSelect(prefix, _) = fun: @unchecked
363363
genLoad(prefix)
364364
}
365365

@@ -725,7 +725,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
725725
lineNumber(app)
726726
app match {
727727
case Apply(_, args) if app.symbol eq defn.newArrayMethod =>
728-
val List(elemClaz, Literal(c: Constant), ArrayValue(_, dims)) = args
728+
val List(elemClaz, Literal(c: Constant), ArrayValue(_, dims)) = args: @unchecked
729729

730730
generatedType = toTypeKind(c.typeValue)
731731
mkArrayConstructorCall(generatedType.asArrayBType, app, dims)
@@ -802,7 +802,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
802802
if (invokeStyle.hasInstance) genLoadQualifier(fun)
803803
genLoadArguments(args, paramTKs(app))
804804

805-
val DesugaredSelect(qual, name) = fun // fun is a Select, also checked in genLoadQualifier
805+
val DesugaredSelect(qual, name) = fun: @unchecked // fun is a Select, also checked in genLoadQualifier
806806
val isArrayClone = name == nme.clone_ && qual.tpe.widen.isInstanceOf[JavaArrayType]
807807
if (isArrayClone) {
808808
// Special-case Array.clone, introduced in 36ef60e. The goal is to generate this call
@@ -845,7 +845,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
845845
} // end of genApply()
846846

847847
private def genArrayValue(av: tpd.JavaSeqLiteral): BType = {
848-
val ArrayValue(tpt, elems) = av
848+
val ArrayValue(tpt, elems) = av: @unchecked
849849

850850
lineNumber(av)
851851
genArray(elems, tpt)
@@ -1530,7 +1530,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
15301530
import ScalaPrimitivesOps.{ ZNOT, ZAND, ZOR, EQ }
15311531

15321532
// lhs and rhs of test
1533-
lazy val DesugaredSelect(lhs, _) = fun
1533+
lazy val DesugaredSelect(lhs, _) = fun: @unchecked
15341534
val rhs = if (args.isEmpty) tpd.EmptyTree else args.head // args.isEmpty only for ZNOT
15351535

15361536
def genZandOrZor(and: Boolean): Unit = {

compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
151151
// sorting ensures nested classes are listed after their enclosing class thus satisfying the Eclipse Java compiler
152152
for (nestedClass <- allNestedClasses.sortBy(_.internalName.toString)) {
153153
// Extract the innerClassEntry - we know it exists, enclosingNestedClassesChain only returns nested classes.
154-
val Some(e) = nestedClass.innerClassAttributeEntry
154+
val Some(e) = nestedClass.innerClassAttributeEntry: @unchecked
155155
jclass.visitInnerClass(e.name, e.outerName, e.innerName, e.flags)
156156
}
157157
}

compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
689689
val origSym = dd.symbol.asTerm
690690
val newSym = makeStatifiedDefSymbol(origSym, origSym.name)
691691
tpd.DefDef(newSym, { paramRefss =>
692-
val selfParamRef :: regularParamRefs = paramRefss.head
692+
val selfParamRef :: regularParamRefs = paramRefss.head: @unchecked
693693
val enclosingClass = origSym.owner.asClass
694694
new TreeTypeMap(
695695
typeMap = _.substThis(enclosingClass, selfParamRef.symbol.termRef)

compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ class JSCodeGen()(using genCtx: Context) {
10251025
*/
10261026

10271027
val (primaryTree :: Nil, secondaryTrees) =
1028-
constructorTrees.partition(_.symbol.isPrimaryConstructor)
1028+
constructorTrees.partition(_.symbol.isPrimaryConstructor): @unchecked
10291029

10301030
val primaryCtor = genPrimaryJSClassCtor(primaryTree)
10311031
val secondaryCtors = secondaryTrees.map(genSecondaryJSClassCtor(_))
@@ -1106,7 +1106,7 @@ class JSCodeGen()(using genCtx: Context) {
11061106

11071107
private def genPrimaryJSClassCtor(dd: DefDef): PrimaryJSCtor = {
11081108
val sym = dd.symbol
1109-
val Block(stats, _) = dd.rhs
1109+
val Block(stats, _) = dd.rhs: @unchecked
11101110
assert(sym.isPrimaryConstructor, s"called with non-primary ctor: $sym")
11111111

11121112
var jsSuperCall: Option[js.JSSuperConstructorCall] = None
@@ -1179,7 +1179,7 @@ class JSCodeGen()(using genCtx: Context) {
11791179

11801180
assert(thisCall.isDefined,
11811181
i"could not find the this() call in secondary JS constructor at ${dd.sourcePos}:\n${stats.map(_.show).mkString("\n")}")
1182-
val Some((targetCtor, ctorArgs)) = thisCall
1182+
val Some((targetCtor, ctorArgs)) = thisCall: @unchecked
11831183

11841184
new SplitSecondaryJSCtor(sym, genParamsAndInfo(sym, dd.paramss),
11851185
beforeThisCall.result(), targetCtor, ctorArgs, afterThisCall.result())
@@ -2139,7 +2139,7 @@ class JSCodeGen()(using genCtx: Context) {
21392139
*/
21402140
private def genSuperCall(tree: Apply, isStat: Boolean): js.Tree = {
21412141
implicit val pos = tree.span
2142-
val Apply(fun @ Select(sup @ Super(qual, _), _), args) = tree
2142+
val Apply(fun @ Select(sup @ Super(qual, _), _), args) = tree: @unchecked
21432143
val sym = fun.symbol
21442144

21452145
if (sym == defn.Any_getClass) {
@@ -2180,7 +2180,7 @@ class JSCodeGen()(using genCtx: Context) {
21802180
private def genApplyNew(tree: Apply): js.Tree = {
21812181
implicit val pos: SourcePosition = tree.sourcePos
21822182

2183-
val Apply(fun @ Select(New(tpt), nme.CONSTRUCTOR), args) = tree
2183+
val Apply(fun @ Select(New(tpt), nme.CONSTRUCTOR), args) = tree: @unchecked
21842184
val ctor = fun.symbol
21852185
val tpe = tpt.tpe
21862186

@@ -2229,7 +2229,7 @@ class JSCodeGen()(using genCtx: Context) {
22292229
acquireContextualJSClassValue { jsClassValue =>
22302230
implicit val pos: Position = tree.span
22312231

2232-
val Apply(fun @ Select(New(tpt), _), args) = tree
2232+
val Apply(fun @ Select(New(tpt), _), args) = tree: @unchecked
22332233
val cls = tpt.tpe.typeSymbol
22342234
val ctor = fun.symbol
22352235

@@ -2898,7 +2898,7 @@ class JSCodeGen()(using genCtx: Context) {
28982898

28992899
implicit val pos = tree.span
29002900

2901-
val Apply(fun, args) = tree
2901+
val Apply(fun, args) = tree: @unchecked
29022902
val arrayObj = qualifierOf(fun)
29032903

29042904
val genArray = genExpr(arrayObj)
@@ -3167,7 +3167,7 @@ class JSCodeGen()(using genCtx: Context) {
31673167
private def genJSSuperCall(tree: Apply, isStat: Boolean): js.Tree = {
31683168
acquireContextualJSClassValue { explicitJSSuperClassValue =>
31693169
implicit val pos = tree.span
3170-
val Apply(fun @ Select(sup @ Super(qual, _), _), args) = tree
3170+
val Apply(fun @ Select(sup @ Super(qual, _), _), args) = tree: @unchecked
31713171
val sym = fun.symbol
31723172

31733173
val genReceiver = genExpr(qual)
@@ -3242,7 +3242,7 @@ class JSCodeGen()(using genCtx: Context) {
32423242
/** Gen JS code for a switch-`Match`, which is translated into an IR `js.Match`. */
32433243
def genMatch(tree: Tree, isStat: Boolean): js.Tree = {
32443244
implicit val pos = tree.span
3245-
val Match(selector, cases) = tree
3245+
val Match(selector, cases) = tree: @unchecked
32463246

32473247
def abortMatch(msg: String): Nothing =
32483248
throw new FatalError(s"$msg in switch-like pattern match at ${tree.span}: $tree")
@@ -3441,7 +3441,7 @@ class JSCodeGen()(using genCtx: Context) {
34413441
val call = if (isStaticCall) {
34423442
genApplyStatic(sym, formalCaptures.map(_.ref) ::: actualParams)
34433443
} else {
3444-
val thisCaptureRef :: argCaptureRefs = formalCaptures.map(_.ref)
3444+
val thisCaptureRef :: argCaptureRefs = formalCaptures.map(_.ref): @unchecked
34453445
if (!sym.owner.isNonNativeJSClass || sym.isJSExposed)
34463446
genApplyMethodMaybeStatically(thisCaptureRef, sym, argCaptureRefs ::: actualParams)
34473447
else
@@ -3458,7 +3458,7 @@ class JSCodeGen()(using genCtx: Context) {
34583458
}
34593459

34603460
if (isThisFunction) {
3461-
val thisParam :: otherParams = formalParams
3461+
val thisParam :: otherParams = formalParams: @unchecked
34623462
js.Closure(
34633463
arrow = false,
34643464
formalCaptures,
@@ -3970,7 +3970,7 @@ class JSCodeGen()(using genCtx: Context) {
39703970
*/
39713971
private def genReflectiveCall(tree: Apply, isSelectDynamic: Boolean): js.Tree = {
39723972
implicit val pos = tree.span
3973-
val Apply(fun @ Select(receiver, _), args) = tree
3973+
val Apply(fun @ Select(receiver, _), args) = tree: @unchecked
39743974

39753975
val selectedValueTree = js.Apply(js.ApplyFlags.empty, genExpr(receiver),
39763976
js.MethodIdent(selectedValueMethodName), Nil)(jstpe.AnyType)
@@ -4213,7 +4213,7 @@ class JSCodeGen()(using genCtx: Context) {
42134213
private def genCaptureValuesFromFakeNewInstance(tree: Tree): List[js.Tree] = {
42144214
implicit val pos: Position = tree.span
42154215

4216-
val Apply(fun @ Select(New(_), _), args) = tree
4216+
val Apply(fun @ Select(New(_), _), args) = tree: @unchecked
42174217
val sym = fun.symbol
42184218

42194219
/* We use the same strategy as genActualJSArgs to detect which parameters were
@@ -4539,7 +4539,7 @@ class JSCodeGen()(using genCtx: Context) {
45394539
pathName.split('.').toList
45404540

45414541
def parseGlobalPath(pathName: String): Global = {
4542-
val globalRef :: path = parsePath(pathName)
4542+
val globalRef :: path = parsePath(pathName): @unchecked
45434543
Global(globalRef, path)
45444544
}
45454545

compiler/src/dotty/tools/backend/sjs/JSExportsGen.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ final class JSExportsGen(jsCodeGen: JSCodeGen)(using Context) {
356356
None
357357
} else {
358358
val formalArgsRegistry = new FormalArgsRegistry(1, false)
359-
val (List(arg), None) = formalArgsRegistry.genFormalArgs()
359+
val (List(arg), None) = formalArgsRegistry.genFormalArgs(): @unchecked
360360
val body = genOverloadDispatchSameArgc(jsName, formalArgsRegistry,
361361
setters.map(new ExportedSymbol(_, static)), jstpe.AnyType, None)
362362
Some((arg, body))

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

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ object desugar {
405405

406406
/** The expansion of a class definition. See inline comments for what is involved */
407407
def classDef(cdef: TypeDef)(using Context): Tree = {
408-
val impl @ Template(constr0, _, self, _) = cdef.rhs
408+
val impl @ Template(constr0, _, self, _) = cdef.rhs: @unchecked
409409
val className = normalizeName(cdef, impl).asTypeName
410410
val parents = impl.parents
411411
val mods = cdef.mods
@@ -695,7 +695,7 @@ object desugar {
695695
.withMods(companionMods | Synthetic))
696696
.withSpan(cdef.span).toList
697697
if (companionDerived.nonEmpty)
698-
for (modClsDef @ TypeDef(_, _) <- mdefs)
698+
for (case modClsDef @ TypeDef(_, _) <- mdefs)
699699
modClsDef.putAttachment(DerivingCompanion, impl.srcPos.startPos)
700700
mdefs
701701
}
@@ -753,7 +753,7 @@ object desugar {
753753

754754
enumCompanionRef match {
755755
case ref: TermRefTree => // have the enum import watch the companion object
756-
val (modVal: ValDef) :: _ = companions
756+
val (modVal: ValDef) :: _ = companions: @unchecked
757757
ref.watching(modVal)
758758
case _ =>
759759
}
@@ -1215,7 +1215,7 @@ object desugar {
12151215

12161216
/** Expand variable identifier x to x @ _ */
12171217
def patternVar(tree: Tree)(using Context): Bind = {
1218-
val Ident(name) = unsplice(tree)
1218+
val Ident(name) = unsplice(tree): @unchecked
12191219
Bind(name, Ident(nme.WILDCARD)).withSpan(tree.span)
12201220
}
12211221

@@ -1553,7 +1553,7 @@ object desugar {
15531553
Function(derivedValDef(gen.pat, named, tpt, EmptyTree, Modifiers(Param)) :: Nil, body)
15541554
case _ =>
15551555
val matchCheckMode =
1556-
if (gen.checkMode == GenCheckMode.Check) MatchCheck.IrrefutableGenFrom
1556+
if (gen.checkMode == GenCheckMode.Check || gen.checkMode == GenCheckMode.CheckAndFilter) MatchCheck.IrrefutableGenFrom
15571557
else MatchCheck.None
15581558
makeCaseLambda(CaseDef(gen.pat, EmptyTree, body) :: Nil, matchCheckMode)
15591559
}
@@ -1640,13 +1640,11 @@ object desugar {
16401640
case IdPattern(_) => true
16411641
case _ => false
16421642

1643-
def needsNoFilter(gen: GenFrom): Boolean =
1644-
if (gen.checkMode == GenCheckMode.FilterAlways) // pattern was prefixed by `case`
1645-
false
1646-
else
1647-
gen.checkMode != GenCheckMode.FilterNow
1648-
|| isVarBinding(gen.pat)
1649-
|| isIrrefutable(gen.pat, gen.expr)
1643+
def needsNoFilter(gen: GenFrom): Boolean = gen.checkMode match
1644+
case GenCheckMode.FilterAlways => false // pattern was prefixed by `case`
1645+
case GenCheckMode.FilterNow | GenCheckMode.CheckAndFilter => isVarBinding(gen.pat) || isIrrefutable(gen.pat, gen.expr)
1646+
case GenCheckMode.Check => true
1647+
case GenCheckMode.Ignore => true
16501648

16511649
/** rhs.name with a pattern filter on rhs unless `pat` is irrefutable when
16521650
* matched against `rhs`.
@@ -1656,10 +1654,6 @@ object desugar {
16561654
Select(rhs, name)
16571655
}
16581656

1659-
def checkMode(gen: GenFrom) =
1660-
if (gen.checkMode == GenCheckMode.Check) MatchCheck.IrrefutableGenFrom
1661-
else MatchCheck.None // refutable paterns were already eliminated in filter step
1662-
16631657
enums match {
16641658
case (gen: GenFrom) :: Nil =>
16651659
Apply(rhsSelect(gen, mapName), makeLambda(gen, body))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ object MainProxies {
183183
case TypeDef(_, template: Template) =>
184184
template.body.flatMap((_: Tree) match {
185185
case dd: DefDef if dd.name.is(DefaultGetterName) && dd.name.firstPart == funSymbol.name =>
186-
val DefaultGetterName.NumberedInfo(index) = dd.name.info
186+
val DefaultGetterName.NumberedInfo(index) = dd.name.info: @unchecked
187187
List(index -> dd.symbol)
188188
case _ => Nil
189189
}).toMap

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
956956
Some(tree.args.head)
957957
else if tree.symbol == defn.QuotedTypeModule_of then
958958
// quoted.Type.of[<body>](quotes)
959-
val TypeApply(_, body :: _) = tree.fun
959+
val TypeApply(_, body :: _) = tree.fun: @unchecked
960960
Some(body)
961961
else None
962962
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,10 @@ class TreeTypeMap(
156156

157157
private def transformAllParamss(paramss: List[ParamClause]): (TreeTypeMap, List[ParamClause]) = paramss match
158158
case params :: paramss1 =>
159-
val (tmap1, params1: ParamClause) = (params: @unchecked) match
159+
val (tmap1, params1: ParamClause) = ((params: @unchecked) match
160160
case ValDefs(vparams) => transformDefs(vparams)
161161
case TypeDefs(tparams) => transformDefs(tparams)
162+
): @unchecked
162163
val (tmap2, paramss2) = tmap1.transformAllParamss(paramss1)
163164
(tmap2, params1 :: paramss2)
164165
case nil =>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
293293
ta.assignType(untpd.TypeDef(sym.name, TypeTree(sym.info)), sym)
294294

295295
def ClassDef(cls: ClassSymbol, constr: DefDef, body: List[Tree], superArgs: List[Tree] = Nil)(using Context): TypeDef = {
296-
val firstParent :: otherParents = cls.info.parents
296+
val firstParent :: otherParents = cls.info.parents: @unchecked
297297
val superRef =
298298
if (cls.is(Trait)) TypeTree(firstParent)
299299
else {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
168168
enum GenCheckMode {
169169
case Ignore // neither filter nor check since filtering was done before
170170
case Check // check that pattern is irrefutable
171-
case FilterNow // filter out non-matching elements since we are not yet in 3.x
171+
case CheckAndFilter // both check and filter (transitional period starting with 3.2)
172+
case FilterNow // filter out non-matching elements if we are not in 3.2 or later
172173
case FilterAlways // filter out non-matching elements since pattern is prefixed by `case`
173174
}
174175

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,9 @@ object Feature:
8888
/** If current source migrates to `version`, issue given warning message
8989
* and return `true`, otherwise return `false`.
9090
*/
91-
def warnOnMigration(msg: Message, pos: SrcPos,
92-
version: SourceVersion)(using Context): Boolean =
91+
def warnOnMigration(msg: Message, pos: SrcPos, version: SourceVersion)(using Context): Boolean =
9392
if sourceVersion.isMigrating && sourceVersion.stable == version
94-
|| (version == `3.0` || version == `3.1` || version == `3.2`) && migrateTo3
93+
|| (version == `3.0` || version == `3.1`) && migrateTo3
9594
then
9695
report.migrationWarning(msg, pos)
9796
true

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import scala.language.unsafeNulls
55

66
import dotty.tools.dotc.config.PathResolver.Defaults
77
import dotty.tools.dotc.config.Settings.{Setting, SettingGroup}
8+
import dotty.tools.dotc.config.SourceVersion
89
import dotty.tools.dotc.core.Contexts._
910
import dotty.tools.dotc.rewrites.Rewrites
1011
import dotty.tools.io.{AbstractFile, Directory, JDK9Reflectors, PlainDirectory}
@@ -31,6 +32,9 @@ object ScalaSettings:
3132
def supportedScalaReleaseVersions: List[String] =
3233
ScalaRelease.values.toList.map(_.show)
3334

35+
def supportedSourceVersions: List[String] =
36+
SourceVersion.values.toList.map(_.toString)
37+
3438
def defaultClasspath: String = sys.env.getOrElse("CLASSPATH", ".")
3539

3640
def defaultPageWidth: Int = {
@@ -51,7 +55,7 @@ trait AllScalaSettings extends CommonScalaSettings, PluginSettings, VerboseSetti
5155
/* Path related settings */
5256
val semanticdbTarget: Setting[String] = PathSetting("-semanticdb-target", "Specify an alternative output directory for SemanticDB files.", "")
5357

54-
val source: Setting[String] = ChoiceSetting("-source", "source version", "source version", List("3.0", "3.1", "future", "3.0-migration", "future-migration"), "3.0", aliases = List("--source"))
58+
val source: Setting[String] = ChoiceSetting("-source", "source version", "source version", ScalaSettings.supportedSourceVersions, SourceVersion.defaultSourceVersion.toString, aliases = List("--source"))
5559
val uniqid: Setting[Boolean] = BooleanSetting("-uniqid", "Uniquely tag all identifiers in debugging output.", aliases = List("--unique-id"))
5660
val rewrite: Setting[Option[Rewrites]] = OptionSetting[Rewrites]("-rewrite", "When used in conjunction with a `...-migration` source version, rewrites sources to migrate to new version.", aliases = List("--rewrite"))
5761
val fromTasty: Setting[Boolean] = BooleanSetting("-from-tasty", "Compile classes from tasty files. The arguments are .tasty or .jar files.", aliases = List("--from-tasty"))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ object Settings:
8484
}
8585

8686
def tryToSet(state: ArgsSummary): ArgsSummary = {
87-
val ArgsSummary(sstate, arg :: args, errors, warnings) = state
87+
val ArgsSummary(sstate, arg :: args, errors, warnings) = state: @unchecked
8888
def update(value: Any, args: List[String]): ArgsSummary =
8989
var dangers = warnings
9090
val value1 =

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import core.Decorators.*
66
import util.Property
77

88
enum SourceVersion:
9-
case `3.0-migration`, `3.0`, `3.1`, `3.2`, `future-migration`, `future`
9+
case `3.0-migration`, `3.0`, `3.1` // Note: do not add `3.1-migration` here, 3.1 is the same language as 3.0.
10+
case `3.2-migration`, `3.2`
11+
case `future-migration`, `future`
1012

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

@@ -16,6 +18,7 @@ enum SourceVersion:
1618
def isAtLeast(v: SourceVersion) = stable.ordinal >= v.ordinal
1719

1820
object SourceVersion extends Property.Key[SourceVersion]:
21+
def defaultSourceVersion = `3.2`
1922

2023
/** language versions that may appear in a language import, are deprecated, but not removed from the standard library. */
2124
val illegalSourceVersionNames = List("3.1-migration").map(_.toTermName)

0 commit comments

Comments
 (0)