Skip to content

Commit

Permalink
Merge pull request #9304 from NthPortal/topic/werror-4/PR
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Nov 23, 2020
2 parents 024a21f + 8447c42 commit 867f63a
Show file tree
Hide file tree
Showing 33 changed files with 129 additions and 100 deletions.
16 changes: 12 additions & 4 deletions build.sbt
Expand Up @@ -512,15 +512,15 @@ lazy val interactive = configureAsSubproject(project)
.settings(
name := "scala-compiler-interactive",
description := "Scala Interactive Compiler",
Compile / scalacOptions ++= Seq("-Xlint", "-Wconf:cat=deprecation:msg=early.initializers:s"),
Compile / scalacOptions ++= Seq("-Xlint", "-Wconf:cat=deprecation&msg=early initializers:s"),
)
.dependsOn(compiler)

lazy val repl = configureAsSubproject(project)
.settings(disableDocs)
.settings(fatalWarningsSettings)
.settings(publish / skip := true)
.settings(Compile / scalacOptions ++= Seq("-Xlint", "-Wconf:cat=deprecation:msg=early.initializers:s"))
.settings(Compile / scalacOptions ++= Seq("-Xlint", "-Wconf:cat=deprecation&msg=early initializers:s"))
.dependsOn(compiler, interactive)

lazy val replFrontend = configureAsSubproject(Project("repl-frontend", file(".") / "src" / "repl-frontend"))
Expand All @@ -540,17 +540,24 @@ lazy val replFrontend = configureAsSubproject(Project("repl-frontend", file(".")

lazy val scaladoc = configureAsSubproject(project)
.settings(disableDocs)
.settings(fatalWarningsSettings)
.settings(publish / skip := true)
.settings(
name := "scala-compiler-doc",
description := "Scala Documentation Generator",
Compile / unmanagedResources / includeFilter := "*.html" | "*.css" | "*.gif" | "*.png" | "*.js" | "*.txt" | "*.svg" | "*.eot" | "*.woff" | "*.ttf",
libraryDependencies ++= ScaladocSettings.webjarResources,
Compile / resourceGenerators += ScaladocSettings.extractResourcesFromWebjar
Compile / resourceGenerators += ScaladocSettings.extractResourcesFromWebjar,
Compile / scalacOptions ++= Seq(
"-Xlint",
"-feature",
"-Wconf:cat=deprecation&msg=early initializers:s",
),
)
.dependsOn(compiler)

lazy val scalap = configureAsSubproject(project)
.settings(fatalWarningsSettings)
.settings(
description := "Scala Bytecode Parser",
// Include decoder.properties
Expand All @@ -575,7 +582,8 @@ lazy val scalap = configureAsSubproject(project)
val excluded = Set("Memoisable.scala", "Result.scala", "Rule.scala", "Rules.scala", "SeqRule.scala")
xs filter { x => !excluded(x.getName) }
},
Compile / headerResources := Nil
Compile / headerResources := Nil,
Compile / scalacOptions ++= Seq("-Xlint", "-feature"),
)
.dependsOn(compiler)

Expand Down
5 changes: 2 additions & 3 deletions src/compiler/scala/reflect/quasiquotes/Reifiers.scala
Expand Up @@ -13,7 +13,6 @@
package scala.reflect
package quasiquotes

import scala.annotation.nowarn
import scala.reflect.reify.{Reifier => ReflectReifier}
import scala.reflect.internal.Flags._

Expand Down Expand Up @@ -86,7 +85,7 @@ trait Reifiers { self: Quasiquotes =>
val isVarPattern = tree match { case Bind(name, Ident(nme.WILDCARD)) => true case _ => false }
val cases =
if(isVarPattern) {
val Ident(name) :: Nil = freevars: @nowarn("msg=match may not be exhaustive")
val Ident(name) :: Nil = freevars: @unchecked
// cq"$name: $treeType => $SomeModule($name)" :: Nil
CaseDef(Bind(name, Typed(Ident(nme.WILDCARD), TypeTree(treeType))),
EmptyTree, Apply(Ident(SomeModule), List(Ident(name)))) :: Nil
Expand Down Expand Up @@ -422,7 +421,7 @@ trait Reifiers { self: Quasiquotes =>
case List(elem) if fill.isDefinedAt(elem) => fill(elem)
case elems => mkList(elems.map(fallback))
}
val head :: tail = group(xs) { (a, b) => !fill.isDefinedAt(a) && !fill.isDefinedAt(b) }: @nowarn("msg=match may not be exhaustive")
val head :: tail = group(xs) { (a, b) => !fill.isDefinedAt(a) && !fill.isDefinedAt(b) }: @unchecked
tail.foldLeft[Tree](reifyGroup(head)) { (tree, lst) => Apply(Select(tree, nme.PLUSPLUS), List(reifyGroup(lst))) }
}

Expand Down
3 changes: 2 additions & 1 deletion src/compiler/scala/tools/nsc/ast/Trees.scala
Expand Up @@ -171,7 +171,8 @@ trait Trees extends scala.reflect.internal.Trees { self: Global =>

type ApiTransformer = super.Transformer

@nowarn("""cat=deprecation&origin=scala\.tools\.nsc\.ast\.Trees\.Transformer""")
// TODO: uncomment when deprecating the below
// @nowarn("""cat=deprecation&origin=scala\.tools\.nsc\.ast\.Trees\.Transformer""")
final type AstTransformer = Transformer

// TODO: deprecate when we can cleanly cross-compile without warnings
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/scala/tools/nsc/backend/jvm/opt/CopyProp.scala
Expand Up @@ -14,7 +14,7 @@ package scala.tools.nsc
package backend.jvm
package opt

import scala.annotation.{nowarn, switch, tailrec}
import scala.annotation.{switch, tailrec}
import scala.collection.mutable
import scala.jdk.CollectionConverters._
import scala.tools.asm.Opcodes._
Expand Down Expand Up @@ -660,7 +660,7 @@ abstract class CopyProp {

@tailrec def tryPairing(): Unit = {
if (completesStackTop(insn)) {
val (store: VarInsnNode, depends) = pairStartStack.pop(): @nowarn("msg=match may not be exhaustive")
val (store: VarInsnNode, depends) = pairStartStack.pop(): @unchecked
addDepends(mkRemovePair(store, insn, depends.toList))
} else if (pairStartStack.nonEmpty) {
val (top, topDepends) = pairStartStack.pop()
Expand Down
3 changes: 1 addition & 2 deletions src/compiler/scala/tools/nsc/tasty/TastyUnpickler.scala
Expand Up @@ -17,7 +17,6 @@ import scala.tools.tasty.{ErasedTypeRef, Signature, TastyFormat, TastyHeaderUnpi
import TastyFormat.NameTags._
import TastyRefs.NameRef
import TastyName._
import scala.annotation.nowarn
import scala.reflect.io.AbstractFile

/**The entry point to TASTy unpickling for nsc, initialises a `TastyUniverse#Context` with the root symbols of a
Expand All @@ -42,7 +41,7 @@ object TastyUnpickler {
val unpickler = new TastyUnpickler[tasty.type](new TastyReader(bytes))(tasty)
unpickler.readHeader()
unpickler.readNames()
val Some(astReader) = unpickler.readSection("ASTs"): @nowarn("msg=match may not be exhaustive")
val Some(astReader) = unpickler.readSection("ASTs"): @unchecked
val treeUnpickler = new TreeUnpickler[tasty.type](astReader, unpickler.nameAtRef)(tasty)
treeUnpickler.enterTopLevel(classRoot, objectRoot)
}
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/scala/tools/nsc/transform/Erasure.scala
Expand Up @@ -13,7 +13,7 @@
package scala.tools.nsc
package transform

import scala.annotation.{nowarn, tailrec}
import scala.annotation.tailrec
import scala.reflect.internal.ClassfileConstants._
import scala.collection.{immutable, mutable}
import symtab._
Expand Down Expand Up @@ -446,7 +446,7 @@ abstract class Erasure extends InfoTransform

case Block(stats, expr) =>
// needs `hasSymbolField` check because `supercall` could be a block (named / default args)
val (presuper, supercall :: rest) = stats span (t => t.hasSymbolWhich(_ hasFlag PRESUPER)): @nowarn("msg=match may not be exhaustive")
val (presuper, supercall :: rest) = stats span (t => t.hasSymbolWhich(_ hasFlag PRESUPER)): @unchecked
treeCopy.Block(tree, presuper ::: (supercall :: mixinConstructorCalls ::: rest), expr)

case x => throw new MatchError(x)
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/scala/tools/nsc/transform/OverridingPairs.scala
Expand Up @@ -25,7 +25,8 @@ import scala.reflect.internal.SymbolPairs
abstract class OverridingPairs extends SymbolPairs {
import global._

@nowarn("""cat=deprecation&origin=scala\.tools\.nsc\.transform\.OverridingPairs\.Cursor""")
// TODO: uncomment when deprecating the below
// @nowarn("""cat=deprecation&origin=scala\.tools\.nsc\.transform\.OverridingPairs\.Cursor""")
final type PairsCursor = Cursor

// TODO: deprecate when we can cleanly cross-compile without warnings
Expand Down
Expand Up @@ -1901,7 +1901,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
private def addBody(tree: DefDef, source: Symbol): DefDef = {
val symbol = tree.symbol
debuglog("specializing body of" + symbol.defString)
val DefDef(_, _, tparams, vparams :: Nil, tpt, _) = tree: @nowarn("msg=match may not be exhaustive")
val DefDef(_, _, tparams, vparams :: Nil, tpt, _) = tree: @unchecked
val env = typeEnv(symbol)
val origtparams = source.typeParams.filter(tparam => !env.contains(tparam) || !isPrimitiveValueType(env(tparam)))
if (origtparams.nonEmpty || symbol.typeParams.nonEmpty)
Expand Down
Expand Up @@ -12,7 +12,6 @@

package scala.tools.nsc.transform.async

import scala.annotation.nowarn
import scala.collection.mutable
import scala.collection.mutable.ListBuffer

Expand Down Expand Up @@ -329,7 +328,7 @@ trait ExprBuilder extends TransformUtils with AsyncAnalysis {
private def buildNestedStatesFirstForInlining(nestedTree: Tree, endState: Int): (AsyncState, List[AsyncState]) = {
val (nestedStats, nestedExpr) = statsAndExpr(nestedTree)
val nestedBuilder = new AsyncBlockBuilder(nestedStats, nestedExpr, currState, endState, StateTransitionStyle.None, Some(this))
val (inlinedState :: Nil, nestedStates) = nestedBuilder.build.partition(_.state == currState): @nowarn("msg=match may not be exhaustive")
val (inlinedState :: Nil, nestedStates) = nestedBuilder.build.partition(_.state == currState): @unchecked
inlinedState.nextStates.foreach(stateBuilder.nextStates += _)
(inlinedState, nestedStates)
}
Expand Down Expand Up @@ -476,7 +475,7 @@ trait ExprBuilder extends TransformUtils with AsyncAnalysis {

// Filter out dead or trivial states.
private def filterStates(all: List[AsyncState]): List[AsyncState] = if (compactStates) {
val (initial :: Nil, rest) = all.partition(_.state == blockBuilder.startState): @nowarn("msg=match may not be exhaustive")
val (initial :: Nil, rest) = all.partition(_.state == blockBuilder.startState): @unchecked
val map = all.iterator.map(x => (x.state, x)).toMap
val seen = mutable.HashSet[Int]()
seen.add(all.last.state)
Expand Down
3 changes: 1 addition & 2 deletions src/compiler/scala/tools/nsc/transform/patmat/Logic.scala
Expand Up @@ -13,7 +13,6 @@
package scala
package tools.nsc.transform.patmat

import scala.annotation.nowarn
import scala.collection.mutable
import scala.collection.immutable.ArraySeq
import scala.reflect.internal.util.Collections._
Expand Down Expand Up @@ -487,7 +486,7 @@ trait Logic extends Debugging {
type Solvable

def propToSolvable(p: Prop): Solvable = {
val (eqAxiom, pure :: Nil) = removeVarEq(List(p), modelNull = false): @nowarn("msg=match may not be exhaustive")
val (eqAxiom, pure :: Nil) = removeVarEq(List(p), modelNull = false): @unchecked
eqFreePropToSolvable(And(eqAxiom, pure))
}

Expand Down
4 changes: 2 additions & 2 deletions src/compiler/scala/tools/nsc/transform/patmat/Solving.scala
Expand Up @@ -14,7 +14,7 @@ package scala.tools.nsc.transform.patmat

import java.util

import scala.annotation.{nowarn, tailrec}
import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer
import scala.collection.{immutable, mutable}
import scala.reflect.internal.util.StatisticsStatics
Expand Down Expand Up @@ -249,7 +249,7 @@ trait Solving extends Logic {
@inline
def /\(a: Lit, b: Lit) = addClauseProcessed(clause(a, b))

val (mid, xn :: Nil) = tail.splitAt(tail.size - 1): @nowarn("msg=match may not be exhaustive")
val (mid, xn :: Nil) = tail.splitAt(tail.size - 1): @unchecked

// 1 <= x1,...,xn <==>
//
Expand Down
3 changes: 1 addition & 2 deletions src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
Expand Up @@ -17,7 +17,6 @@ import symtab.Flags._
import scala.collection.mutable
import scala.reflect.ClassTag
import PartialFunction.{cond => when}
import scala.annotation.nowarn

/**
* @author Lukas Rytz
Expand Down Expand Up @@ -529,7 +528,7 @@ trait NamesDefaults { self: Analyzer =>
val namelessArgs = {
var positionalAllowed = true
def stripNamedArg(arg: NamedArg, argIndex: Int): Tree = {
val NamedArg(Ident(name), rhs) = arg: @nowarn("msg=match may not be exhaustive")
val NamedArg(Ident(name), rhs) = arg: @unchecked
params indexWhere (p => matchesName(p, name, argIndex)) match {
case -1 =>
val warnVariableInScope = !currentRun.isScala3 && context0.lookupSymbol(name, _.isVariable).isSuccess
Expand Down
7 changes: 3 additions & 4 deletions src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
Expand Up @@ -21,7 +21,6 @@ package typechecker

import scala.collection.{immutable, mutable}
import mutable.ListBuffer
import scala.annotation.nowarn
import scala.tools.nsc.Reporting.WarningCategory
import symtab.Flags._

Expand Down Expand Up @@ -144,7 +143,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
}

private def transformSuperSelect(sel: Select): Tree = {
val Select(sup @ Super(_, mix), name) = sel: @nowarn("msg=match may not be exhaustive")
val Select(sup @ Super(_, mix), name) = sel: @unchecked
val sym = sel.symbol
val clazz = sup.symbol

Expand Down Expand Up @@ -485,7 +484,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
newAcc setInfoAndEnter accType(newAcc)

val code = DefDef(newAcc, {
val (receiver :: _) :: tail = newAcc.paramss: @nowarn("msg=match may not be exhaustive")
val (receiver :: _) :: tail = newAcc.paramss: @unchecked
val base: Tree = Select(Ident(receiver), sym)
foldLeft2(tail, sym.info.paramss)(base){ (acc, params, pps) =>
val y = map2(params, pps)( (param, pp) => makeArg(param, receiver, pp.tpe))
Expand Down Expand Up @@ -550,7 +549,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
val accessorType = MethodType(params, UnitTpe)

protAcc setInfoAndEnter accessorType
val obj :: value :: Nil = params: @nowarn("msg=match may not be exhaustive")
val obj :: value :: Nil = params: @unchecked
storeAccessorDefinition(clazz, DefDef(protAcc, Assign(Select(Ident(obj), field.name), Ident(value))))

protAcc
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/typechecker/Typers.scala
Expand Up @@ -1695,7 +1695,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
private def normalizeFirstParent(parents: List[Tree]): List[Tree] = {
@annotation.tailrec
def explode0(parents: List[Tree]): List[Tree] = {
val supertpt :: rest = parents: @nowarn("msg=match may not be exhaustive") // parents is always non-empty here - it only grows
val supertpt :: rest = parents: @unchecked // parents is always non-empty here - it only grows
if (supertpt.tpe.typeSymbol == AnyClass) {
supertpt setType AnyRefTpe
parents
Expand Down
2 changes: 1 addition & 1 deletion src/scaladoc/scala/tools/nsc/doc/Index.scala
Expand Up @@ -12,7 +12,7 @@

package scala.tools.nsc.doc

import scala.collection._
import scala.collection.immutable.{SortedMap, SortedSet}

trait Index {
type SymbolMap = SortedMap[String, SortedSet[model.MemberEntity]]
Expand Down
4 changes: 2 additions & 2 deletions src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala
Expand Up @@ -163,7 +163,7 @@ abstract class ScaladocSyntaxAnalyzer[G <: Global](val global: G) extends Syntax
*/
override def discardDocBuffer() = {
import scala.tools.nsc.doc.base.comment.Comment
val doc = flushDoc
val doc = flushDoc()
// tags that make a local double-star comment look unclean, as though it were API
def unclean(comment: Comment): Boolean = {
import comment._
Expand All @@ -182,7 +182,7 @@ abstract class ScaladocSyntaxAnalyzer[G <: Global](val global: G) extends Syntax
override def withPatches(patches: List[BracePatch]) = new ScaladocUnitParser(unit, patches)

override def joinComment(trees: => List[Tree]): List[Tree] = {
val doc = in.flushDoc
val doc = in.flushDoc()
if ((doc ne null) && doc.raw.length > 0) {
log(s"joinComment(doc=$doc)")
val joined = trees map {
Expand Down
2 changes: 2 additions & 0 deletions src/scaladoc/scala/tools/nsc/doc/Settings.scala
Expand Up @@ -15,6 +15,7 @@ package doc

import java.io.File

import scala.annotation.nowarn
import scala.tools.nsc.settings.{DefaultPathFactory, PathFactory}

/** An extended version of compiler settings, with additional Scaladoc-specific options.
Expand Down Expand Up @@ -349,6 +350,7 @@ class Settings(error: String => Unit, val printMsg: String => Unit = println(_),
/** Dirty, dirty, dirty hack: the value params conversions can all kick in -- and they are disambiguated by priority
* but showing priority in scaladoc would make no sense -- so we have to manually remove the conversions that we
* know will never get a chance to kick in. Anyway, DIRTY DIRTY DIRTY! */
@nowarn("cat=lint-nonlocal-return")
def valueClassFilter(value: String, conversionName: String): Boolean = {
val valueName = value.toLowerCase
val otherValues = valueClassList.filterNot(_ == valueName)
Expand Down
34 changes: 23 additions & 11 deletions src/scaladoc/scala/tools/nsc/doc/base/CommentFactoryBase.scala
Expand Up @@ -15,7 +15,7 @@ package doc
package base

import base.comment._
import scala.annotation.tailrec
import scala.annotation.{nowarn, tailrec}
import scala.collection._
import scala.util.matching.Regex
import scala.reflect.internal.util.Position
Expand Down Expand Up @@ -183,11 +183,11 @@ trait CommentFactoryBase { this: MemberLookupBase =>

/** The start of a Scaladoc code block */
private val CodeBlockStartRegex =
new Regex("""(.*?)((?:\{\{\{)|(?:\u000E<pre(?: [^>]*)?>\u000E))(.*)""")
new Regex("""(.*?)((?:\{\{\{)|(?:<pre(?: [^>]*)?>))(.*)""")

/** The end of a Scaladoc code block */
private val CodeBlockEndRegex =
new Regex("""(.*?)((?:\}\}\})|(?:\u000E</pre>\u000E))(.*)""")
new Regex("""(.*?)((?:\}\}\})|(?:</pre>))(.*)""")

/** A key used for a tag map. The key is built from the name of the tag and
* from the linked symbol if the tag has one.
Expand Down Expand Up @@ -771,12 +771,13 @@ trait CommentFactoryBase { this: MemberLookupBase =>
}

// TODO: Abandon table parsing when the delimiter is missing instead of fixing and continuing.
val delimiterRow :: dataRows = if (rows.nonEmpty)
rows.toList
else {
reportError(pos, "Fixing missing delimiter row", site)
Row(Cell(Paragraph(Text("-")) :: Nil) :: Nil) :: Nil
}
val delimiterRow :: dataRows = {
if (rows.nonEmpty) rows.toList
else {
reportError(pos, "Fixing missing delimiter row", site)
Row(Cell(Paragraph(Text("-")) :: Nil) :: Nil) :: Nil
}
}: @nowarn("msg=match may not be exhaustive")

if (delimiterRow.cells.isEmpty) sys.error("TODO: Handle table with empty delimiter row")

Expand Down Expand Up @@ -893,15 +894,26 @@ trait CommentFactoryBase { this: MemberLookupBase =>
else if (check(",,")) subscript()
else if (check("[[")) link()
else {
val str = readUntil { char == safeTagMarker || check("''") || char == '`' || check("__") || char == '^' || check(",,") || check("[[") || isInlineEnd || checkParaEnded || char == endOfLine }
val str = readUntil {
char == safeTagMarker ||
check("''") ||
char == '`' ||
check("__") ||
char == '^' ||
check(",,") ||
check("[[") ||
isInlineEnd ||
checkParaEnded() ||
char == endOfLine
}
Text(textTransform(str))
}
}

val inlines: List[Inline] = {
val iss = mutable.ListBuffer.empty[Inline]
iss += inline0()
while (!isInlineEnd && !checkParaEnded) {
while (!isInlineEnd && !checkParaEnded()) {
val skipEndOfLine = if (char == endOfLine) {
nextChar()
true
Expand Down

0 comments on commit 867f63a

Please sign in to comment.