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

[REVISIT] Dogfood value discard [ci: last-only] #10476

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 7 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,13 @@ lazy val commonSettings = instanceSettings ++ clearSourceAndResourceDirectories
Compile / scalacOptions += "-Wconf:cat=optimizer:is",
// We use @nowarn for some methods that are deprecated in Java > 8
Compile / scalacOptions += "-Wconf:cat=unused-nowarn:s",
Compile / scalacOptions ++= Seq("-deprecation", "-feature"),
Compile / scalacOptions ++= Seq(
"-deprecation",
"-feature",
//"-Wvalue-discard", // await restarr
//"-Wnonunit-statement", // await restarr
//"-Wnonunit-if:false", // uncomment to ignore one-legged if or case
),
Compile / doc / scalacOptions ++= Seq(
"-doc-footer", "epfl",
"-diagrams",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package scala.reflect.macros
package compiler

import scala.annotation.nowarn
import scala.tools.nsc.Global

abstract class DefaultMacroCompiler extends Resolvers
Expand Down Expand Up @@ -82,7 +83,8 @@ abstract class DefaultMacroCompiler extends Resolvers
if (vanillaResult.isSuccess && bundleResult.isSuccess) MacroImplAmbiguousError()
}

def reportMostAppropriateFailure() = {
@nowarn("cat=w-flag-value-discard")
def reportMostAppropriateFailure(): Unit = {
typer.silent(_.typedTypeConstructor(maybeBundleRef)) match {
case SilentResultValue(result) if looksLikeMacroBundleType(result.tpe) =>
val bundle = result.tpe.typeSymbol
Expand Down
1 change: 1 addition & 0 deletions src/compiler/scala/reflect/reify/Reifier.scala
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ abstract class Reifier extends States
if (reifyDebug) println("=============================")
} else {
reifyTrace("reification = ")(untyped)
()
}

untyped
Expand Down
6 changes: 4 additions & 2 deletions src/compiler/scala/reflect/reify/codegen/GenTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
package scala.reflect.reify
package codegen

import scala.annotation.nowarn

trait GenTypes {
self: Reifier =>

Expand Down Expand Up @@ -187,13 +189,13 @@ trait GenTypes {

tpe match {
case tpe @ RefinedType(parents, decls) =>
reifySymDef(tpe.typeSymbol)
reifySymDef(tpe.typeSymbol): @nowarn("cat=w-flag-value-discard")
mirrorBuildCall(nme.RefinedType, reify(parents), reifyScope(decls), reify(tpe.typeSymbol))
case tpe @ ExistentialType(tparams, underlying) =>
tparams foreach reifySymDef
reifyBuildCall(nme.ExistentialType, tparams, underlying)
case tpe @ ClassInfoType(parents, decls, clazz) =>
reifySymDef(clazz)
reifySymDef(clazz): @nowarn("cat=w-flag-value-discard")
mirrorBuildCall(nme.ClassInfoType, reify(parents), reifyScope(decls), reify(tpe.typeSymbol))
case tpe @ MethodType(params, restpe) =>
params foreach reifySymDef
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

package scala.tools.nsc

import scala.annotation.nowarn
import scala.io.StdIn.readLine

/**
Expand Down Expand Up @@ -39,6 +40,7 @@ object ClassPathMemoryConsumptionTester {
else doTest(args)
}

@nowarn("cat=w-flag-value-discard")
private def doTest(args: Array[String]) = {
val settings = loadSettings(args.toList)

Expand All @@ -50,7 +52,7 @@ object ClassPathMemoryConsumptionTester {
println(s"Loading classpath ${settings.requiredInstances.value} times")
val startTime = System.currentTimeMillis()

mains map (_.process(baseArgs))
mains.map(_.process(baseArgs))

val elapsed = System.currentTimeMillis() - startTime
println(s"Operation finished - elapsed $elapsed ms")
Expand All @@ -72,7 +74,7 @@ object ClassPathMemoryConsumptionTester {

private def loadSettings(args: List[String]) = {
val settings = new TestSettings()
settings.processArguments(args, processAll = true)
settings.processArguments(args, processAll = true): @nowarn("cat=w-flag-value-discard")
if (settings.classpath.isDefault)
settings.classpath.value = System.getProperty("java.class.path", ".")
settings
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/Global.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,7 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
case -1 => mkName(str)
case idx =>
val phasePart = str drop (idx + 1)
settings.Yshow.tryToSetColon(phasePart.split(',').toList)
settings.Yshow.tryToSetColon(phasePart.split(',').toList): @nowarn("cat=w-flag-value-discard")
mkName(str take idx)
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/compiler/scala/tools/nsc/MainBench.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

package scala.tools.nsc

import scala.annotation.nowarn

/** The main class for NSC, a compiler for the programming
* language Scala.
*/
Expand All @@ -32,7 +34,7 @@ object MainBench extends Driver with EvalLoop {
theCompiler.settings.Ystatistics.value = List("all")
theCompiler.settings.YhotStatisticsEnabled.value = true
}
process(args)
process(args): @nowarn("cat=w-flag-value-discard")
val end = System.nanoTime()
val duration = (end-start)/1000000
println(s"${duration}ms")
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/PipelineMain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ class PipelineMainClass(argFiles: Seq[Path], pipelineSettings: PipelineMain.Pipe
def durationMs: Double = {
val result = (endNanos - startNanos).toDouble / 1000 / 1000
if (result < 0)
getClass
getClass: @nowarn("cat=w-flag-value-discard")
result
}
def startMicros: Double = startNanos.toDouble / 1000d
Expand Down
9 changes: 5 additions & 4 deletions src/compiler/scala/tools/nsc/ScriptRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

package scala.tools.nsc

import scala.annotation.nowarn
import scala.reflect.io.{ AbstractFile, Directory, File, Path }
import scala.tools.nsc.classpath.ClassPathFactory
import scala.tools.nsc.io.Jar
Expand Down Expand Up @@ -96,7 +97,7 @@ abstract class AbstractScriptRunner(settings: GenericRunnerSettings) extends Scr
else
Directory.makeTemp("scalascript").tap { tmp =>
// delete the directory after the user code has finished
Runtime.getRuntime.addShutdownHook(new Thread(() => tmp.deleteRecursively()))
Runtime.getRuntime.addShutdownHook(new Thread(() => tmp.deleteRecursively(): @nowarn("cat=w-flag-value-discard")))
settings.outdir.value = tmp.path
}

Expand All @@ -120,7 +121,7 @@ abstract class AbstractScriptRunner(settings: GenericRunnerSettings) extends Scr
def jarOK = jarFile.canRead && jarFile.isFresher(File(scriptFile))

def recompile(): Option[Throwable] = {
jarFile.delete()
jarFile.delete(): @nowarn("cat=w-flag-value-discard")

compile match {
case Some(compiledPath) =>
Expand All @@ -131,7 +132,7 @@ abstract class AbstractScriptRunner(settings: GenericRunnerSettings) extends Scr
Jar.create(jarFile, compiledPath.toDirectory, mainClass)
None
} catch {
case NonFatal(e) => jarFile.delete() ; Some(e)
case NonFatal(e) => jarFile.delete(): @nowarn("cat=w-flag-value-discard"); Some(e)
}
} else None
} else Some(NoScriptError)
Expand Down Expand Up @@ -186,7 +187,7 @@ abstract class AbstractScriptRunner(settings: GenericRunnerSettings) extends Scr
catch {
case NonFatal(e) => Some(e)
}
finally scriptFile.delete() // in case there was a compilation error
finally scriptFile.delete(): @nowarn("cat=w-flag-value-discard") // in case there was a compilation error
}
}

Expand Down
13 changes: 6 additions & 7 deletions src/compiler/scala/tools/nsc/ast/NodePrinters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ package scala.tools.nsc
package ast

import java.lang.System.{lineSeparator => EOL}
import symtab.Flags._
import scala.annotation.nowarn
import scala.reflect.internal.util.ListOfNil
import symtab.Flags._

/** The object `nodePrinter` converts the internal tree
* representation to a string.
Expand Down Expand Up @@ -183,9 +184,7 @@ abstract class NodePrinters {
}

def treePrefix(tree: Tree) = showPosition(tree) + tree.productPrefix
def printMultiline(tree: Tree)(body: => Unit): Unit = {
printMultiline(treePrefix(tree), showAttributes(tree))(body)
}
def printMultiline(tree: Tree)(body: => Unit): Unit = printMultiline(treePrefix(tree), showAttributes(tree))(body)
def printMultiline(prefix: String, comment: String)(body: => Unit): Unit = {
printLine(prefix + "(", comment)
indent(body)
Expand Down Expand Up @@ -214,7 +213,7 @@ abstract class NodePrinters {
}

def traverse(tree: Tree): Unit = {
showPosition(tree)
showPosition(tree): @nowarn("cat=w-flag-value-discard")

tree match {
case ApplyDynamic(fun, args) => applyCommon(tree, fun, args)
Expand All @@ -234,7 +233,7 @@ abstract class NodePrinters {

case ld @ LabelDef(name, params, rhs) =>
printMultiline(tree) {
showNameAndPos(ld)
showNameAndPos(ld): @nowarn("cat=w-flag-value-discard")
traverseList("()", "params")(params)
traverse(rhs)
}
Expand Down Expand Up @@ -311,7 +310,7 @@ abstract class NodePrinters {
case Super(qual, mix) =>
printMultiline(tree) {
traverse(qual)
showName(mix)
showName(mix): @nowarn("cat=w-flag-value-discard")
}
case Template(parents, self, body) =>
printMultiline(tree) {
Expand Down
5 changes: 3 additions & 2 deletions src/compiler/scala/tools/nsc/ast/TreeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ package ast

import scala.annotation.tailrec
import scala.collection.mutable.ListBuffer
import symtab.Flags._
import scala.reflect.internal.util.FreshNameCreator
import scala.reflect.internal.util.ListOfNil
import symtab.Flags._

/** XXX to resolve: TreeGen only assumes global is a SymbolTable, but
* TreeDSL at the moment expects a Global. Can we get by with SymbolTable?
Expand Down Expand Up @@ -382,7 +382,8 @@ abstract class TreeGen extends scala.reflect.internal.TreeGen with TreeDSL {
defineOriginalOwner(anonClass, fun.symbol.originalOwner)

val samDef = mkMethodFromFunction(localTyper)(anonClass, fun)
anonClass.info.decls enter samDef.symbol
val samDefSym = samDef.symbol
anonClass.info.decls.enter(samDefSym)

localTyper.typedPos(fun.pos) {
Block(
Expand Down
9 changes: 5 additions & 4 deletions src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package scala.tools.nsc
package ast.parser

import scala.annotation.nowarn
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.BufferedIterator
Expand Down Expand Up @@ -318,7 +319,7 @@ trait MarkupParsers {
debugLastStartElement.push((start, qname))
val ts = content
xEndTag(qname)
debugLastStartElement.pop()
debugLastStartElement.pop(): @nowarn("cat=w-flag-value-discard")
val pos = r2p(start, start, curOffset)
qname match {
case "xml:group" => handle.group(pos, ts)
Expand Down Expand Up @@ -382,14 +383,14 @@ trait MarkupParsers {

val ts = new ArrayBuffer[Tree]
val start = curOffset - 1 // include <
content_LT(ts)
content_LT(ts): @nowarn("cat=w-flag-value-discard")

// parse more XML?
if (charComingAfter(xSpaceOpt()) == '<') {
do {
xSpaceOpt()
nextch()
content_LT(ts)
content_LT(ts): @nowarn("cat=w-flag-value-discard")
} while (charComingAfter(xSpaceOpt()) == '<')
handle.makeXMLseq(r2p(start, start, curOffset), ts)
}
Expand Down Expand Up @@ -484,7 +485,7 @@ trait MarkupParsers {

while (doPattern) { } // call until false
xEndTag(qname)
debugLastStartElement.pop()
debugLastStartElement.pop(): @nowarn("cat=w-flag-value-discard")
}

handle.makeXMLpat(r2p(start, start, curOffset), qname, ts)
Expand Down
Loading