summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-04-15 18:30:58 +0000
committerPaul Phillips <paulp@improving.org>2010-04-15 18:30:58 +0000
commit4fb3473182262b7cce33406ba7d0701e6622e3c3 (patch)
treeba2ce46bf92c86cf36095cb0c3b4da30c4d8a305
parent348271c8b27af1c29f7705ea2853c934492ee327 (diff)
downloadscala-4fb3473182262b7cce33406ba7d0701e6622e3c3.tar.gz
scala-4fb3473182262b7cce33406ba7d0701e6622e3c3.tar.bz2
scala-4fb3473182262b7cce33406ba7d0701e6622e3c3.zip
Removed a bunch of -Y warning options.
back in the form of a compiler plugin. Also promoted -Yfatal-warnings to -Xfatal-warnings: this is key to writing tests which involve warnings and should be at least semi-supported. Closes #3300, no review.
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala2
-rw-r--r--src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala2
-rw-r--r--src/compiler/scala/tools/nsc/settings/ScalaSettings.scala17
-rw-r--r--src/compiler/scala/tools/nsc/transform/TailCalls.scala16
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala5
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala88
-rw-r--r--test/files/neg/migration28.flags2
-rw-r--r--test/files/neg/t3115.flags2
-rw-r--r--test/files/pos/bug3097.flags2
10 files changed, 12 insertions, 126 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index 16bff5d399..b43908c4f9 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -137,7 +137,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
def error(msg: String) = reporter.error(NoPosition, msg)
def warning(msg: String) =
- if (settings.Ywarnfatal.value) reporter.error(NoPosition, msg)
+ if (settings.Xwarnfatal.value) reporter.error(NoPosition, msg)
else reporter.warning(NoPosition, msg)
def inform(msg: String) = reporter.info(NoPosition, msg, true)
def inform[T](msg: String, value: T): T = { inform(msg+value); value }
diff --git a/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala b/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala
index ce10f560e9..e35843fc9c 100644
--- a/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala
+++ b/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala
@@ -29,7 +29,7 @@ abstract class AbstractReporter extends Reporter {
protected def info0(pos: Position, msg: String, _severity: Severity, force: Boolean) {
val severity =
- if (settings.Ywarnfatal.value && _severity == WARNING) ERROR
+ if (settings.Xwarnfatal.value && _severity == WARNING) ERROR
else _severity
severity match {
diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
index 1b6b8297ef..54f4146f31 100644
--- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
@@ -27,7 +27,6 @@ trait ScalaSettings extends AbsScalaSettings with StandardScalaSettings {
* Temporary Settings
*/
val suppressVTWarn = BooleanSetting ("-Ysuppress-vt-typer-warnings", "Suppress warnings from the typer when testing the virtual class encoding, NOT FOR FINAL!")
- val javaignorecp = BooleanSetting ("-javaignorecp", "Does nothing - is being removed.") // !!! marked for death, but need new starr.
/**
* Standard settings
@@ -80,6 +79,9 @@ trait ScalaSettings extends AbsScalaSettings with StandardScalaSettings {
val Xshowobj = StringSetting ("-Xshow-object", "object", "Show object info", "")
val showPhases = BooleanSetting ("-Xshow-phases", "Print a synopsis of compiler phases")
val sourceReader = StringSetting ("-Xsource-reader", "classname", "Specify a custom method for reading source files", "scala.tools.nsc.io.SourceReader")
+ val Xwarnfatal = BooleanSetting ("-Xfatal-warnings", "Fail the compilation if there are any warnings.")
+ val Xwarninit = BooleanSetting ("-Xwarninit", "Warn about possible changes in initialization semantics")
+ val Xchecknull = BooleanSetting ("-Xcheck-null", "Emit warning on selection of nullable reference")
/** Compatibility stubs for options whose value name did
* not previously match the option name.
@@ -134,20 +136,11 @@ trait ScalaSettings extends AbsScalaSettings with StandardScalaSettings {
val Ypmatdebug = BooleanSetting ("-Ypmat-debug", "Trace all pattern matcher activity.")
val Yrepldebug = BooleanSetting ("-Yrepl-debug", "Trace all repl activity.")
val Ypmatnaive = BooleanSetting ("-Ypmat-naive", "Desugar matches as naively as possible..")
- val Ytailrec = BooleanSetting ("-Ytailrecommend", "Alert methods which would be tail-recursive if private or final.")
val Yjenkins = BooleanSetting ("-Yjenkins-hashCodes", "Use jenkins hash algorithm for case class generated hashCodes.")
// Warnings
- val Ywarnfatal = BooleanSetting ("-Yfatal-warnings", "Fail the compilation if there are any warnings.")
- val Xwarninit = BooleanSetting ("-Xwarninit", "Warn about possible changes in initialization semantics")
- val Xchecknull = BooleanSetting ("-Xcheck-null", "Emit warning on selection of nullable reference")
- val Xwarndeadcode = BooleanSetting ("-Ywarn-dead-code", "Emit warnings for dead code")
- val YwarnShadow = BooleanSetting ("-Ywarn-shadowing", "Emit warnings about possible variable shadowing.")
- val YwarnCatches = BooleanSetting ("-Ywarn-catches", "Emit warnings about catch blocks which catch everything.")
- val Xwarnings = BooleanSetting ("-Xstrict-warnings", "Emit warnings about lots of things.") .
- withPostSetHook(_ =>
- List(YwarnShadow, YwarnCatches, Xwarndeadcode, Xwarninit) foreach (_.value = true)
- )
+ val Ywarndeadcode = BooleanSetting ("-Ywarn-dead-code", "Emit warnings for dead code")
+
/**
* "fsc-specific" settings.
*/
diff --git a/src/compiler/scala/tools/nsc/transform/TailCalls.scala b/src/compiler/scala/tools/nsc/transform/TailCalls.scala
index adeab550ee..effc75486d 100644
--- a/src/compiler/scala/tools/nsc/transform/TailCalls.scala
+++ b/src/compiler/scala/tools/nsc/transform/TailCalls.scala
@@ -163,15 +163,8 @@ abstract class TailCalls extends Transform
newCtx.tailPos = true
val isEligible = newCtx.currentMethod.isEffectivelyFinal || (newCtx.currentMethod.enclClass hasFlag Flags.MODULE)
- // If -Ytailrecommend is given, we speculatively try transforming ineligible methods and
- // report where we would have been successful.
- val recommend = settings.Ytailrec.value
- val savedFlags: Option[Long] = if (recommend) Some(newCtx.currentMethod.flags) else None
-
- if (isEligible || recommend) {
- if (recommend)
- newCtx.currentMethod.flags |= Flags.FINAL
+ if (isEligible) {
newCtx.tparams = Nil
log(" Considering " + name + " for tailcalls")
tree.symbol.tpe match {
@@ -185,7 +178,6 @@ abstract class TailCalls extends Transform
val t1 = treeCopy.DefDef(tree, mods, name, tparams, vparams, tpt, {
val transformed = transform(rhs, newCtx)
- savedFlags foreach (newCtx.currentMethod.flags = _)
transformed match {
case newRHS if isEligible && newCtx.accessed =>
@@ -200,12 +192,6 @@ abstract class TailCalls extends Transform
List(ValDef(newThis, This(currentClass))),
LabelDef(newCtx.label, newThis :: (vparams.flatten map (_.symbol)), newRHS)
)))
- case _ if recommend =>
- if (newCtx.accessed)
- unit.warning(dd.pos, "method is tailrecommended")
- // transform with the original flags restored
- transform(rhs, newCtx)
-
case rhs => rhs
}
})
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index e339560837..bad98193b0 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -659,11 +659,6 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
}
treeCopy.DefDef(tree, mods, name, tparams, List(vparamss.flatten), tpt, rhs1)
case Try(body, catches, finalizer) =>
- // If warnings are enabled, alert about promiscuously catching cases.
- if (settings.YwarnCatches.value)
- for (cd <- catches find treeInfo.catchesThrowable)
- unit.warning(cd.pos, "catch clause swallows everything: not advised.")
-
if (catches forall treeInfo.isCatchCase) tree
else {
val exname = unit.fresh.newName(tree.pos, "ex$")
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index c8d3308077..4557f7bde1 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -1591,7 +1591,7 @@ trait Infer {
}
def checkDead(tree: Tree): Tree = {
- if (settings.Xwarndeadcode.value && tree.tpe != null && tree.tpe.typeSymbol == NothingClass)
+ if (settings.Ywarndeadcode.value && tree.tpe != null && tree.tpe.typeSymbol == NothingClass)
context.warning (tree.pos, "dead code following this construct")
tree
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 3fe937f241..0274dc8871 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1676,77 +1676,6 @@ trait Typers { self: Analyzer =>
}
}
- /** does given name name an identifier visible at this point?
- *
- * @param name the given name
- * @return <code>true</code> if an identifier with the given name is visible.
- */
- def namesSomeIdent(name: Name): Boolean = namesWhatIdent(name).isDefined
-
- /** If this name returns a visible identifier, return its symbol.
- *
- * @param name the given name
- * @return <code>Some(sym)</code> if an ident is visible, None otherwise.
- */
- def namesWhatIdent(name: Name): Option[Symbol] = {
- var cx = context
- while (cx != NoContext) {
- val pre = cx.enclClass.prefix
- val defEntry = cx.scope.lookupEntry(name)
- if ((defEntry ne null) && reallyExists(defEntry.sym))
- return Some(defEntry.sym)
-
- cx = cx.enclClass
- (pre member name filter (sym => reallyExists(sym) && context.isAccessible(sym, pre, false))) match {
- case NoSymbol => cx = cx.outer
- case other => return Some(other)
- }
- }
- context.imports map (_ importedSymbol name) find (_ != NoSymbol)
- }
-
- /** Does this tree declare a val or def with the same name as one in scope?
- * This only catches identifiers in the same file, so more work is needed.
- *
- * @param tree the given tree
- * @param filt filter for any conflicting symbols found -- false means ignore
- */
- def checkShadowings(tree: Tree, filt: (Symbol) => Boolean = _ => true) {
- def sameFile(other: Symbol) =
- (tree.symbol != null) && tree.symbol.sourceFile == other.sourceFile
- def inFile(other: Symbol) =
- if (sameFile(other)) ""
- else if (other.sourceFile != null) "in %s ".format(other.sourceFile)
- else ""
-
- def positionStr(other: Symbol) = other.pos match {
- case NoPosition => inFile(other) match { case "" => "(location unknown) " ; case x => x }
- case pos => "%sat line %s\n%s".format(inFile(other), pos.line, pos.lineContent) + """ /* is shadowed by */"""
- }
- def include(v: ValOrDefDef, other: Symbol) = {
- // shadowing on the same line is a good bet for noise
- (v.pos == NoPosition || other.pos == NoPosition || v.pos.line != other.pos.line) &&
- // not likely we'll shadow a whole package without realizing it
- !other.isPackage &&
- // (v.symbol == null || !v.symbol.hasTransOwner(other)) &&
- filt(other)
- }
-
- tree match {
- // while I try to figure out how to limit the noise far enough to make this
- // genuinely useful, I'm setting minimum identifier length to 3 to omit all
- // those x's and i's we so enjoy reusing.
- case v: ValOrDefDef if v.name.toString.length > 2 =>
- namesWhatIdent(v.name) map { other =>
- if (include(v, other) && unit != null) {
- val fstr = "%s (%s) shadows usage %s"
- unit.warning(v.pos, fstr.format(v.name, v.tpt, positionStr(other)))
- }
- }
- case _ =>
- }
- }
-
def typedUseCase(useCase: UseCase) {
def stringParser(str: String): syntaxAnalyzer.Parser = {
val file = new BatchSourceFile(context.unit.source.file, str) {
@@ -1793,15 +1722,6 @@ trait Typers { self: Analyzer =>
def typedDefDef(ddef: DefDef): DefDef = {
val meth = ddef.symbol
- // If warnings are enabled, attempt to alert about variable shadowing. This only
- // catches method parameters shadowing identifiers declared in the same file, so more
- // work is needed. Most of the code here is to filter out false positives.
- def isAuxConstructor(sym: Symbol) = sym.isConstructor && !sym.isPrimaryConstructor
- if (settings.YwarnShadow.value && !isAuxConstructor(ddef.symbol)) {
- for (v <- ddef.vparamss.flatten ; if v.symbol != null && !(v.symbol hasFlag SYNTHETIC))
- checkShadowings(v, (sym => !sym.isDeferred && !sym.isMethod))
- }
-
reenterTypeParams(ddef.tparams)
reenterValueParams(ddef.vparamss)
@@ -1933,7 +1853,6 @@ trait Typers { self: Analyzer =>
while ((e ne null) && (e.sym ne stat.symbol)) e = e.tail
if (e eq null) context.scope.enter(stat.symbol)
}
- if (settings.YwarnShadow.value) checkShadowings(stat)
enterLabelDef(stat)
}
if (phaseId(currentPeriod) <= currentRun.typerPhase.id) {
@@ -3114,13 +3033,6 @@ trait Typers { self: Analyzer =>
if (vble == NoSymbol)
vble = context.owner.newValue(tree.pos, name)
if (vble.name.toTermName != nme.WILDCARD) {
-/*
- if (namesSomeIdent(vble.name))
- context.warning(tree.pos,
- "pattern variable"+vble.name+" shadows a value visible in the environment;\n"+
- "use backquotes `"+vble.name+"` if you mean to match against that value;\n" +
- "or rename the variable or use an explicit bind "+vble.name+"@_ to avoid this warning.")
-*/
if ((mode & ALTmode) != 0)
error(tree.pos, "illegal variable in pattern alternative")
vble = namer.enterInScope(vble)
diff --git a/test/files/neg/migration28.flags b/test/files/neg/migration28.flags
index f7025d0226..197b3198c8 100644
--- a/test/files/neg/migration28.flags
+++ b/test/files/neg/migration28.flags
@@ -1 +1 @@
--Yfatal-warnings -Xmigration
+-Xfatal-warnings -Xmigration
diff --git a/test/files/neg/t3115.flags b/test/files/neg/t3115.flags
index bf8f88334b..d1b831ea87 100644
--- a/test/files/neg/t3115.flags
+++ b/test/files/neg/t3115.flags
@@ -1 +1 @@
--deprecation -Yfatal-warnings \ No newline at end of file
+-deprecation -Xfatal-warnings \ No newline at end of file
diff --git a/test/files/pos/bug3097.flags b/test/files/pos/bug3097.flags
index 570b15929d..144ddac9d3 100644
--- a/test/files/pos/bug3097.flags
+++ b/test/files/pos/bug3097.flags
@@ -1 +1 @@
--unchecked -Yfatal-warnings
+-unchecked -Xfatal-warnings