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

There is no more -Xsource:2.14, only -Xsource:3 #8812

Merged
merged 1 commit into from Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/scala/reflect/macros/contexts/FrontEnds.scala
Expand Up @@ -28,7 +28,7 @@ trait FrontEnds {

def hasErrors: Boolean = universe.reporter.hasErrors

// TODO: add WarningCategory parameter in 2.14 (not binary compatible)
// TODO: add WarningCategory parameter (not binary compatible)
def warning(pos: Position, msg: String): Unit = callsiteTyper.context.warning(pos, msg, WarningCategory.Other)

def error(pos: Position, msg: String): Unit = callsiteTyper.context.error(pos, msg)
Expand Down
3 changes: 1 addition & 2 deletions src/compiler/scala/tools/nsc/Global.scala
Expand Up @@ -1137,8 +1137,7 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
// We hit these checks regularly. They shouldn't change inside the same run, so cache the comparisons here.
val isScala212: Boolean = settings.isScala212
val isScala213: Boolean = settings.isScala213
val isScala214: Boolean = settings.isScala214
val isScala300: Boolean = settings.isScala300
val isScala3: Boolean = settings.isScala3

// used in sbt
def uncheckedWarnings: List[(Position, String)] = reporting.uncheckedWarnings
Expand Down
1 change: 0 additions & 1 deletion src/compiler/scala/tools/nsc/Parsing.scala
Expand Up @@ -23,7 +23,6 @@ trait Parsing { self : Positions with Reporting =>
trait RunParsing {
val parsing: PerRunParsing = new PerRunParsing
def isScala213: Boolean
def isScala214: Boolean
}

class PerRunParsing {
Expand Down
26 changes: 13 additions & 13 deletions src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
Expand Up @@ -1313,7 +1313,7 @@ self =>
else if (in.token == SYMBOLLIT) {
def msg(what: String) =
s"""symbol literal is $what; use Symbol("${in.strVal}") instead"""
if (settings.isScala214) syntaxError(in.offset, msg("unsupported"))
if (settings.isScala3) syntaxError(in.offset, msg("unsupported"))
else deprecationWarning(in.offset, msg("deprecated"), "2.13.0")
Apply(scalaDot(nme.Symbol), List(finish(in.strVal)))
}
Expand Down Expand Up @@ -1907,7 +1907,7 @@ self =>
def msg(what: String, instead: String): String = s"`val` keyword in for comprehension is $what: $instead"
if (hasEq) {
val without = "instead, bind the value without `val`"
if (currentRun.isScala214) syntaxError(in.offset, msg("unsupported", without))
if (currentRun.isScala3) syntaxError(in.offset, msg("unsupported", without))
else deprecationWarning(in.offset, msg("deprecated", without), "2.10.0")
}
else syntaxError(in.offset, msg("unsupported", "just remove `val`"))
Expand Down Expand Up @@ -2462,7 +2462,7 @@ self =>
def msg(what: String) = s"""view bounds are $what; use an implicit parameter instead.
| example: instead of `def f[A <% Int](a: A)` use `def f[A](a: A)(implicit ev: A => Int)`""".stripMargin
while (in.token == VIEWBOUND) {
if (currentRun.isScala214) syntaxError(in.offset, msg("unsupported"))
if (currentRun.isScala3) syntaxError(in.offset, msg("unsupported"))
else deprecationWarning(in.offset, msg("deprecated"), "2.12.0")
contextBoundBuf += atPos(in.skipToken())(makeFunctionTypeTree(List(Ident(pname)), typ()))
}
Expand Down Expand Up @@ -2744,8 +2744,8 @@ self =>
val vparamss = paramClauses(nme.CONSTRUCTOR, classContextBounds map (_.duplicate), ofCaseClass = false)
newLineOptWhenFollowedBy(LBRACE)
val rhs = in.token match {
case LBRACE if !currentRun.isScala214 => missingEquals(); atPos(in.offset) { constrBlock(vparamss) }
case _ => accept(EQUALS) ; atPos(in.offset) { constrExpr(vparamss) }
case LBRACE if !currentRun.isScala3 => missingEquals(); atPos(in.offset) { constrBlock(vparamss) }
case _ => accept(EQUALS) ; atPos(in.offset) { constrExpr(vparamss) }
}
DefDef(mods, nme.CONSTRUCTOR, List(), vparamss, TypeTree(), rhs)
}
Expand Down Expand Up @@ -2773,14 +2773,14 @@ self =>
val rhs =
if (isStatSep || in.token == RBRACE) {
if (restype.isEmpty) {
if (currentRun.isScala214) syntaxError(in.lastOffset, msg("unsupported", ": Unit"))
if (currentRun.isScala3) syntaxError(in.lastOffset, msg("unsupported", ": Unit"))
else deprecationWarning(in.lastOffset, msg("deprecated", ": Unit"), "2.13.0")
restype = scalaUnitConstr
}
newmods |= Flags.DEFERRED
EmptyTree
} else if (restype.isEmpty && in.token == LBRACE) {
if (currentRun.isScala214) syntaxError(in.offset, msg("unsupported", ": Unit ="))
if (currentRun.isScala3) syntaxError(in.offset, msg("unsupported", ": Unit ="))
else deprecationWarning(in.offset, msg("deprecated", ": Unit ="), "2.13.0")
restype = scalaUnitConstr
blockExpr()
Expand Down Expand Up @@ -2922,7 +2922,7 @@ self =>
classContextBounds = contextBoundBuf.toList
val tstart = (in.offset :: classContextBounds.map(_.pos.start)).min
if (!classContextBounds.isEmpty && mods.isTrait) {
val viewBoundsExist = if (currentRun.isScala214) "" else " nor view bounds `<% ...`"
val viewBoundsExist = if (currentRun.isScala3) "" else " nor view bounds `<% ...`"
syntaxError(s"traits cannot have type parameters with context bounds `: ...`$viewBoundsExist", skipIt = false)
classContextBounds = List()
}
Expand Down Expand Up @@ -3016,8 +3016,8 @@ self =>
val (self, body) = templateBody(isPre = true)
if (in.token == WITH && (self eq noSelfType)) {
val advice =
if (currentRun.isScala214) "use trait parameters instead."
else "they will be replaced by trait parameters in 2.14, see the migration guide on avoiding var/val in traits."
if (currentRun.isScala3) "use trait parameters instead."
else "they will be replaced by trait parameters in 3.0, see the migration guide on avoiding var/val in traits."
deprecationWarning(braceOffset, s"early initializers are deprecated; $advice", "2.13.0")
val earlyDefs: List[Tree] = body.map(ensureEarlyDef).filter(_.nonEmpty)
in.nextToken()
Expand All @@ -3039,7 +3039,7 @@ self =>
copyValDef(vdef)(mods = mods | Flags.PRESUPER)
case tdef @ TypeDef(mods, name, tparams, rhs) =>
def msg(what: String): String = s"early type members are $what: move them to the regular body; the semantics are the same"
if (currentRun.isScala214) syntaxError(tdef.pos.point, msg("unsupported"))
if (currentRun.isScala3) syntaxError(tdef.pos.point, msg("unsupported"))
else deprecationWarning(tdef.pos.point, msg("deprecated"), "2.11.0")
treeCopy.TypeDef(tdef, mods | Flags.PRESUPER, name, tparams, rhs)
case docdef @ DocDef(comm, rhs) =>
Expand Down Expand Up @@ -3082,9 +3082,9 @@ self =>
val tstart1 = if (body.isEmpty && in.lastOffset < tstart) in.lastOffset else tstart

// we can't easily check this later, because `gen.mkParents` adds the default AnyRef parent, and we need to warn based on what the user wrote
if (name == nme.PACKAGEkw && parents.nonEmpty && settings.isScala214)
if (name == nme.PACKAGEkw && parents.nonEmpty && settings.isScala3)
deprecationWarning(tstart, s"package object inheritance is deprecated (https://github.com/scala/scala-dev/issues/441);\n" +
s"drop the `extends` clause or use a regular object instead", "2.14.0")
s"drop the `extends` clause or use a regular object instead", "3.0.0")

atPos(tstart1) {
// Exclude only the 9 primitives plus AnyVal.
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
Expand Up @@ -452,7 +452,7 @@ trait Scanners extends ScannersCommon {
(sepRegions.isEmpty || sepRegions.head == RBRACE)) {
if (pastBlankLine()) insertNL(NEWLINES)
else if (!isLeadingInfixOperator) insertNL(NEWLINE)
else if (!currentRun.isScala214) {
else if (!currentRun.isScala3) {
val msg = """|Line starts with an operator that in future
|will be taken as an infix expression continued from the previous line.
|To force the previous interpretation as a separate statement,
Expand Down Expand Up @@ -874,7 +874,7 @@ trait Scanners extends ScannersCommon {
nextRawChar()
if (isTripleQuote()) {
setStrVal()
if(!currentRun.isScala214) replaceUnicodeEscapesInTriple()
if(!currentRun.isScala3) replaceUnicodeEscapesInTriple()
token = STRINGLIT
} else
getRawStringLit()
Expand Down
13 changes: 7 additions & 6 deletions src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
Expand Up @@ -93,17 +93,16 @@ trait ScalaSettings extends StandardScalaSettings with Warnings {
def releaseValue: Option[String] = Option(release.value).filter(_ != "")

/*
* The previous "-source" option is intended to be used mainly
* The previous "-Xsource" option is intended to be used mainly
* though this helper.
*/
private[this] val version212 = ScalaVersion("2.12.0")
def isScala212: Boolean = source.value >= version212
private[this] val version213 = ScalaVersion("2.13.0")
def isScala213: Boolean = source.value >= version213
private[this] val version214 = ScalaVersion("2.14.0")
def isScala214: Boolean = source.value >= version214
private[this] val version300 = ScalaVersion("3.0.0")
def isScala300: Boolean = source.value >= version300
private[this] val version3 = ScalaVersion("3.0.0")
def isScala3: Boolean = source.value >= version3

/**
* -X "Advanced" settings
Expand Down Expand Up @@ -133,8 +132,10 @@ trait ScalaSettings extends StandardScalaSettings with Warnings {
val mainClass = StringSetting ("-Xmain-class", "path", "Class for manifest's Main-Class entry (only useful with -d <jar>)", "")
val sourceReader = StringSetting ("-Xsource-reader", "classname", "Specify a custom method for reading source files.", "")
val reporter = StringSetting ("-Xreporter", "classname", "Specify a custom subclass of FilteringReporter for compiler messages.", "scala.tools.nsc.reporters.ConsoleReporter")
val source = ScalaVersionSetting ("-Xsource", "version", "Enable features that will be available in a future version of Scala, for purposes of early migration and alpha testing.", initial = version213).withPostSetHook(s =>
if (s.value < version213) errorFn.apply(s"-Xsource must be at least the current major version (${version213.versionString})"))
val source = ScalaVersionSetting ("-Xsource", "version", "Enable features that will be available in a future version of Scala, for purposes of early migration and alpha testing.", initial = version213).withPostSetHook { s =>
if (s.value < version213) errorFn.apply(s"-Xsource must be at least the current major version (${version213.versionString})")
if (s.value >= version214 && s.value < version3) s.withDeprecationMessage("instead of -Xsource:2.14, use -Xsource:3").value = version3
}

val XnoPatmatAnalysis = BooleanSetting ("-Xno-patmat-analysis", "Don't perform exhaustivity/unreachability analysis. Also, ignore @switch annotation.")

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/typechecker/Adaptations.scala
Expand Up @@ -94,7 +94,7 @@ trait Adaptations {
true // keep adaptation
}
if (args.isEmpty) {
if (currentRun.isScala300) noAdaptation else deprecatedAdaptation
if (currentRun.isScala3) noAdaptation else deprecatedAdaptation
} else
warnAdaptation
}
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/scala/tools/nsc/typechecker/Contexts.scala
Expand Up @@ -1049,9 +1049,9 @@ trait Contexts { self: Analyzer =>
sym.isImplicit &&
isAccessible(sym, pre) &&
!(
// [eed3si9n] ideally I'd like to do this: val fd = currentRun.isScala214 && sym.isDeprecated
// [eed3si9n] ideally I'd like to do this: val fd = currentRun.isScala3 && sym.isDeprecated
// but implicit caching currently does not report sym.isDeprecated correctly.
currentRun.isScala214 && (sym == currentRun.runDefinitions.Predef_any2stringaddMethod)
currentRun.isScala3 && (sym == currentRun.runDefinitions.Predef_any2stringaddMethod)
) &&
!(imported && {
val e = scope.lookupEntry(name)
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/typechecker/Infer.scala
Expand Up @@ -905,7 +905,7 @@ trait Infer extends Checkable {
case _ =>
tpe2 match {
case PolyType(tparams2, rtpe2) => isAsSpecificValueType(tpe1, rtpe2, undef1, undef2 ::: tparams2)
case _ if !currentRun.isScala300 => existentialAbstraction(undef1, tpe1) <:< existentialAbstraction(undef2, tpe2)
case _ if !currentRun.isScala3 => existentialAbstraction(undef1, tpe1) <:< existentialAbstraction(undef2, tpe2)
case _ =>
// Backport of fix for https://github.com/scala/bug/issues/2509
// from Dotty https://github.com/lampepfl/dotty/commit/89540268e6c49fb92b9ca61249e46bb59981bf5a
Expand Down
Expand Up @@ -529,7 +529,7 @@ trait NamesDefaults { self: Analyzer =>
val NamedArg(Ident(name), rhs) = arg
params indexWhere (p => matchesName(p, name, argIndex)) match {
case -1 =>
val warnVariableInScope = !currentRun.isScala214 && context0.lookupSymbol(name, _.isVariable).isSuccess
val warnVariableInScope = !currentRun.isScala3 && context0.lookupSymbol(name, _.isVariable).isSuccess
UnknownParameterNameNamesDefaultError(arg, name, warnVariableInScope)
case paramPos if argPos contains paramPos =>
val existingArgIndex = argPos.indexWhere(_ == paramPos)
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
Expand Up @@ -824,7 +824,7 @@ abstract class RefChecks extends Transform {
.filter(c => c.exists && c.isClass)
overridden foreach { sym2 =>
def msg(what: String) = s"shadowing a nested class of a parent is $what but $clazz shadows $sym2 defined in ${sym2.owner}; rename the class to something else"
if (currentRun.isScala300) reporter.error(clazz.pos, msg("unsupported"))
if (currentRun.isScala3) reporter.error(clazz.pos, msg("unsupported"))
else runReporting.deprecationWarning(clazz.pos, clazz, currentOwner, msg("deprecated"), "2.13.2")
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/compiler/scala/tools/nsc/typechecker/Typers.scala
Expand Up @@ -899,7 +899,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper

val arity = mt.params.length

val sourceLevel2_14 = currentRun.isScala214
val sourceLevel3 = currentRun.isScala3

def warnTree = original orElse tree

Expand Down Expand Up @@ -927,15 +927,15 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
// until 2.13:
// - for arity > 0: function or sam type is expected
// - for arity == 0: Function0 is expected -- SAM types do not eta-expand because it could be an accidental SAM scala/bug#9489
// 2.14:
// 3.0:
// - for arity > 0: unconditional
// - for arity == 0: a function-ish type of arity 0 is expected (including SAM)
//
// warnings:
// - 2.12: eta-expansion of zero-arg methods was deprecated (scala/bug#7187)
// - 2.13: deprecation dropped in favor of setting the scene for uniform eta-expansion in 3.0
// (arity > 0) expected type is a SAM that is not annotated with `@FunctionalInterface`
// - 2.14: (arity == 0) expected type is a SAM that is not annotated with `@FunctionalInterface`
// - 3.0: (arity == 0) expected type is a SAM that is not annotated with `@FunctionalInterface`
def checkCanEtaExpand(): Boolean = {
def expectingSamOfArity = {
val sam = samOf(ptUnderlying)
Expand All @@ -950,7 +950,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
val doIt =
if (arity == 0) {
val doEtaZero =
expectingFunctionOfArity || sourceLevel2_14 && expectingSamOfArity
expectingFunctionOfArity || sourceLevel3 && expectingSamOfArity

if (doEtaZero && settings.warnEtaZero) {
val ptHelp =
Expand All @@ -963,7 +963,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
WarningCategory.LintEtaZero)
}
doEtaZero
} else sourceLevel2_14 || expectingFunctionOfArity || expectingSamOfArity
} else sourceLevel3 || expectingFunctionOfArity || expectingSamOfArity

if (doIt && !expectingFunctionOfArity && settings.warnEtaSam) warnEtaSam()

Expand All @@ -979,7 +979,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
}
// (4.2) condition for auto-application by -Xsource level
//
// until 2.14: none (assuming condition for (4.3) was not met)
// until 3.0: none (assuming condition for (4.3) was not met)
// in 3.0: `meth.isJavaDefined`
// (TODO decide -- currently the condition is more involved to give slack to Scala methods overriding Java-defined ones;
// I think we should resolve that by introducing slack in overriding e.g. a Java-defined `def toString()` by a Scala-defined `def toString`.
Expand All @@ -988,10 +988,10 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
// > val vparamSymssOrEmptyParamsFromOverride =
// This means an accessor that overrides a Java-defined method gets a MethodType instead of a NullaryMethodType, which breaks lots of assumptions about accessors)
def checkCanAutoApply(): Boolean = {
if (sourceLevel2_14 && !isPastTyper && !matchNullaryLoosely) {
if (sourceLevel3 && !isPastTyper && !matchNullaryLoosely) {
context.deprecationWarning(tree.pos, NoSymbol, s"Auto-application to `()` is deprecated. Supply the empty argument list `()` explicitly to invoke method ${meth.decodedName},\n" +
s"or remove the empty argument list from its definition (Java-defined methods are exempt).\n"+
s"In Scala 3, an unapplied method like this will be eta-expanded into a function.", "2.14.0")
s"In Scala 3, an unapplied method like this will be eta-expanded into a function.", "3.0.0")
}
true
}
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/scala/tools/nsc/typechecker/Unapplies.scala
Expand Up @@ -98,7 +98,7 @@ trait Unapplies extends ast.TreeDSL {


private def applyShouldInheritAccess(mods: Modifiers) =
currentRun.isScala214 && (mods.hasFlag(PRIVATE) || (!mods.hasFlag(PROTECTED) && mods.hasAccessBoundary))
currentRun.isScala3 && (mods.hasFlag(PRIVATE) || (!mods.hasFlag(PROTECTED) && mods.hasAccessBoundary))

/** The module corresponding to a case class; overrides toString to show the module's name
*/
Expand Down Expand Up @@ -272,7 +272,7 @@ trait Unapplies extends ast.TreeDSL {
val argss = mmap(paramss)(toIdent)
val body: Tree = New(classTpe, argss)
val copyMods =
if (currentRun.isScala214) {
if (currentRun.isScala3) {
val inheritedMods = constrMods(cdef)
Modifiers(SYNTHETIC | (inheritedMods.flags & AccessFlags), inheritedMods.privateWithin)
}
Expand Down
Expand Up @@ -32,7 +32,7 @@ trait FastStringInterpolator extends FormatInterpolator {
val treated =
try
parts.mapConserve { case lit@Literal(Constant(stringVal: String)) =>
val k = Constant(if (isRaw && currentRun.isScala214) stringVal
val k = Constant(if (isRaw && currentRun.isScala3) stringVal
else if (isRaw) {
val processed = StringContext.processUnicode(stringVal)
if(processed != stringVal){
Expand Down
2 changes: 1 addition & 1 deletion src/library/scala/SerialVersionUID.scala
Expand Up @@ -23,5 +23,5 @@ package scala
* @see [[http://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html `java.io.Serializable`]]
* @see [[Serializable]]
*/
@deprecatedInheritance("Scheduled for being final in 2.14", "2.13.0")
@deprecatedInheritance("Scheduled for being final in the future", "2.13.0")
class SerialVersionUID(value: Long) extends scala.annotation.ConstantAnnotation
2 changes: 1 addition & 1 deletion src/library/scala/StringContext.scala
Expand Up @@ -138,7 +138,7 @@ case class StringContext(parts: String*) {
*
* ''Note:'' Even when using the raw interpolator, Scala will process Unicode escapes.
* Unicode processing in the raw interpolator is deprecated as of scala 2.13.2 and
* will be removed in scala 2.14
* will be removed in the future
dwijnand marked this conversation as resolved.
Show resolved Hide resolved
* For example:
* {{{
* scala> raw"\u005cu0023"
Expand Down