Skip to content

Commit 83e95c0

Browse files
committed
Merge pull request scala#2831 from soc/SI-7624
SI-7624 Fix -feature and some -Xlint warnings
2 parents b45f71e + a4a43a1 commit 83e95c0

File tree

93 files changed

+1346
-2610
lines changed

Some content is hidden

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

93 files changed

+1346
-2610
lines changed

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ TODO:
395395
<property name="scalac.args" value=""/>
396396
<property name="javac.args" value=""/>
397397

398-
<property name="scalac.args.always" value="" />
398+
<property name="scalac.args.always" value="-feature" />
399399
<property name="scalac.args.optimise" value=""/> <!-- scalac.args.optimise is selectively overridden in certain antcall tasks. -->
400400
<property name="scalac.args.all" value="${scalac.args.always} ${scalac.args} ${scalac.args.optimise}"/>
401401
<property name="scalac.args.locker" value="${scalac.args.all}"/>

src/actors/scala/actors/Scheduler.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
package scala.actors
1111

12-
import java.util.concurrent._
1312
import scheduler.{DelegatingScheduler, ForkJoinScheduler, ResizableThreadPoolScheduler, ThreadPoolConfig}
1413

1514
/**

src/actors/scala/actors/remote/TcpService.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ object TcpService {
6767
timeout =>
6868
try {
6969
val to = timeout.toInt
70-
Debug.info("Using socket timeout $to")
70+
Debug.info(s"Using socket timeout $to")
7171
Some(to)
7272
} catch {
7373
case e: NumberFormatException =>

src/compiler/scala/reflect/macros/compiler/DefaultMacroCompiler.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package scala.reflect.macros
22
package compiler
33

44
import scala.tools.nsc.Global
5-
import scala.reflect.macros.contexts.Context
65

76
abstract class DefaultMacroCompiler extends Resolvers
87
with Validators
@@ -11,7 +10,6 @@ abstract class DefaultMacroCompiler extends Resolvers
1110
import global._
1211

1312
val typer: global.analyzer.Typer
14-
private implicit val context0 = typer.context
1513
val context = typer.context
1614

1715
val macroDdef: DefDef

src/compiler/scala/reflect/macros/compiler/Validators.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ trait Validators {
1111
import global._
1212
import analyzer._
1313
import definitions._
14-
import treeInfo._
15-
import typer.infer._
1614

1715
def validateMacroImplRef() = {
1816
sanityCheck()

src/compiler/scala/reflect/macros/runtime/JavaReflectionRuntimes.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ trait JavaReflectionRuntimes {
1010
trait JavaReflectionResolvers {
1111
self: MacroRuntimeResolver =>
1212

13-
import global._
14-
1513
def resolveJavaReflectionRuntime(classLoader: ClassLoader): MacroRuntime = {
1614
val implClass = Class.forName(className, true, classLoader)
1715
val implMeths = implClass.getDeclaredMethods.find(_.getName == methName)

src/compiler/scala/reflect/macros/runtime/MacroRuntimes.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package scala.reflect.macros
22
package runtime
33

4-
import scala.collection.mutable.{Map => MutableMap}
54
import scala.reflect.internal.Flags._
65
import scala.reflect.runtime.ReflectionUtils
7-
import scala.tools.nsc.util.ScalaClassLoader
8-
import scala.tools.nsc.util.AbstractFileClassLoader
96

107
trait MacroRuntimes extends JavaReflectionRuntimes with ScalaReflectionRuntimes {
118
self: scala.tools.nsc.typechecker.Analyzer =>

src/compiler/scala/reflect/macros/runtime/ScalaReflectionRuntimes.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ trait ScalaReflectionRuntimes {
99
trait ScalaReflectionResolvers {
1010
self: MacroRuntimeResolver =>
1111

12-
import global._
13-
1412
def resolveScalaReflectionRuntime(classLoader: ClassLoader): MacroRuntime = {
1513
val macroMirror: ru.JavaMirror = ru.runtimeMirror(classLoader)
1614
val implContainerSym = macroMirror.classSymbol(Class.forName(className, true, classLoader))

src/compiler/scala/reflect/macros/util/Helpers.scala

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ trait Helpers {
2323
* or to streamline creation of the list of macro arguments.
2424
*/
2525
def transformTypeTagEvidenceParams(macroImplRef: Tree, transform: (Symbol, Symbol) => Symbol): List[List[Symbol]] = {
26-
val treeInfo.MacroImplReference(isBundle, owner, macroImpl, _) = macroImplRef
26+
val treeInfo.MacroImplReference(isBundle, _, macroImpl, _) = macroImplRef
2727
val paramss = macroImpl.paramss
2828
if (paramss.isEmpty || paramss.last.isEmpty) return paramss // no implicit parameters in the signature => nothing to do
2929
val rc =
@@ -44,11 +44,6 @@ trait Helpers {
4444
if (transformed.isEmpty) paramss.init else paramss.init :+ transformed
4545
}
4646

47-
private def dealiasAndRewrap(tp: Type)(fn: Type => Type): Type = {
48-
if (isRepeatedParamType(tp)) scalaRepeatedType(fn(tp.typeArgs.head.dealias))
49-
else fn(tp.dealias)
50-
}
51-
5247
/** Increases metalevel of the type, i.e. transforms:
5348
* * T to c.Expr[T]
5449
*

src/compiler/scala/tools/ant/sabbus/Settings.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class Settings {
9393
case _ => false
9494
}
9595

96-
override lazy val hashCode: Int = Seq(
96+
override lazy val hashCode: Int = Seq[Any](
9797
gBf,
9898
uncheckedBf,
9999
classpathBf,

src/compiler/scala/tools/cmd/CommandLineParser.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ object CommandLineParser {
4040
// parse `in` for an argument, return it and the remainder of the input (or an error message)
4141
// (argument may be in single/double quotes, taking escaping into account, quotes are stripped)
4242
private def argument(in: String): Either[String, (String, String)] = in match {
43-
case DoubleQuoted(arg, rest) => Right(arg, rest)
44-
case SingleQuoted(arg, rest) => Right(arg, rest)
45-
case Word(arg, rest) => Right(arg, rest)
46-
case _ => Left("Illegal argument: "+ in)
43+
case DoubleQuoted(arg, rest) => Right((arg, rest))
44+
case SingleQuoted(arg, rest) => Right((arg, rest))
45+
case Word(arg, rest) => Right((arg, rest))
46+
case _ => Left(s"Illegal argument: $in")
4747
}
4848

4949
// parse a list of whitespace-separated arguments (ignoring whitespace in quoted arguments)
5050
@tailrec private def commandLine(in: String, accum: List[String] = Nil): Either[String, (List[String], String)] = {
5151
val trimmed = in.trim
52-
if (trimmed.isEmpty) Right(accum.reverse, "")
52+
if (trimmed.isEmpty) Right((accum.reverse, ""))
5353
else argument(trimmed) match {
5454
case Right((arg, next)) =>
5555
(next span Character.isWhitespace) match {

src/compiler/scala/tools/cmd/gen/AnyVals.scala

Lines changed: 44 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,23 @@
66
package scala.tools.cmd
77
package gen
88

9-
/** Code generation of the AnyVal types and their companions.
10-
*/
9+
/** Code generation of the AnyVal types and their companions. */
1110
trait AnyValReps {
1211
self: AnyVals =>
1312

14-
sealed abstract class AnyValNum(name: String, repr: Option[String], javaEquiv: String) extends AnyValRep(name,repr,javaEquiv) {
13+
sealed abstract class AnyValNum(name: String, repr: Option[String], javaEquiv: String)
14+
extends AnyValRep(name,repr,javaEquiv) {
1515

1616
case class Op(op : String, doc : String)
1717

1818
private def companionCoercions(tos: AnyValRep*) = {
1919
tos.toList map (to =>
20-
"""implicit def @javaequiv@2%s(x: @name@): %s = x.to%s""".format(to.javaEquiv, to.name, to.name)
20+
s"implicit def @javaequiv@2${to.javaEquiv}(x: @name@): ${to.name} = x.to${to.name}"
2121
)
2222
}
23-
def coercionCommentExtra = ""
24-
def coercionComment = """
25-
/** Language mandated coercions from @name@ to "wider" types.%s
26-
*/""".format(coercionCommentExtra)
23+
def coercionComment =
24+
"""/** Language mandated coercions from @name@ to "wider" types. */
25+
import scala.language.implicitConversions"""
2726

2827
def implicitCoercions: List[String] = {
2928
val coercions = this match {
@@ -41,12 +40,8 @@ trait AnyValReps {
4140
def isCardinal: Boolean = isIntegerType(this)
4241
def unaryOps = {
4342
val ops = List(
44-
Op("+", "/**\n" +
45-
" * Returns this value, unmodified.\n" +
46-
" */"),
47-
Op("-", "/**\n" +
48-
" * Returns the negation of this value.\n" +
49-
" */"))
43+
Op("+", "/** Returns this value, unmodified. */"),
44+
Op("-", "/** Returns the negation of this value. */"))
5045

5146
if(isCardinal)
5247
Op("~", "/**\n" +
@@ -95,7 +90,7 @@ trait AnyValReps {
9590
" */"))
9691
else Nil
9792

98-
def shiftOps =
93+
def shiftOps =
9994
if (isCardinal)
10095
List(
10196
Op("<<", "/**\n" +
@@ -127,20 +122,20 @@ trait AnyValReps {
127122
" */"))
128123
else Nil
129124

130-
def comparisonOps = List(
131-
Op("==", "/**\n * Returns `true` if this value is equal to x, `false` otherwise.\n */"),
132-
Op("!=", "/**\n * Returns `true` if this value is not equal to x, `false` otherwise.\n */"),
133-
Op("<", "/**\n * Returns `true` if this value is less than x, `false` otherwise.\n */"),
134-
Op("<=", "/**\n * Returns `true` if this value is less than or equal to x, `false` otherwise.\n */"),
135-
Op(">", "/**\n * Returns `true` if this value is greater than x, `false` otherwise.\n */"),
136-
Op(">=", "/**\n * Returns `true` if this value is greater than or equal to x, `false` otherwise.\n */"))
125+
def comparisonOps = List(
126+
Op("==", "/** Returns `true` if this value is equal to x, `false` otherwise. */"),
127+
Op("!=", "/** Returns `true` if this value is not equal to x, `false` otherwise. */"),
128+
Op("<", "/** Returns `true` if this value is less than x, `false` otherwise. */"),
129+
Op("<=", "/** Returns `true` if this value is less than or equal to x, `false` otherwise. */"),
130+
Op(">", "/** Returns `true` if this value is greater than x, `false` otherwise. */"),
131+
Op(">=", "/** Returns `true` if this value is greater than or equal to x, `false` otherwise. */"))
137132

138133
def otherOps = List(
139-
Op("+", "/**\n * Returns the sum of this value and `x`.\n */"),
140-
Op("-", "/**\n * Returns the difference of this value and `x`.\n */"),
141-
Op("*", "/**\n * Returns the product of this value and `x`.\n */"),
142-
Op("/", "/**\n * Returns the quotient of this value and `x`.\n */"),
143-
Op("%", "/**\n * Returns the remainder of the division of this value by `x`.\n */"))
134+
Op("+", "/** Returns the sum of this value and `x`. */"),
135+
Op("-", "/** Returns the difference of this value and `x`. */"),
136+
Op("*", "/** Returns the product of this value and `x`. */"),
137+
Op("/", "/** Returns the quotient of this value and `x`. */"),
138+
Op("%", "/** Returns the remainder of the division of this value by `x`. */"))
144139

145140
// Given two numeric value types S and T , the operation type of S and T is defined as follows:
146141
// If both S and T are subrange types then the operation type of S and T is Int.
@@ -278,21 +273,21 @@ trait AnyValReps {
278273
}
279274

280275
trait AnyValTemplates {
281-
def headerTemplate = ("""
282-
/* __ *\
276+
def headerTemplate = """/* __ *\
283277
** ________ ___ / / ___ Scala API **
284278
** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
285279
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
286280
** /____/\___/_/ |_/____/_/ | | **
287281
** |/ **
288282
\* */
289283
290-
%s
291-
package scala
284+
// DO NOT EDIT, CHANGES WILL BE LOST
285+
// This auto-generated code can be modified in scala.tools.cmd.gen.
286+
// Afterwards, running tools/codegen-anyvals regenerates this source file.
292287
293-
import scala.language.implicitConversions
288+
package scala
294289
295-
""".trim.format(timestampString) + "\n\n")
290+
"""
296291

297292
def classDocTemplate = ("""
298293
/** `@name@`@representation@ (equivalent to Java's `@javaequiv@` primitive type) is a
@@ -304,8 +299,6 @@ import scala.language.implicitConversions
304299
*/
305300
""".trim + "\n")
306301

307-
def timestampString = "// DO NOT EDIT, CHANGES WILL BE LOST.\n"
308-
309302
def allCompanions = """
310303
/** Transform a value type into a boxed reference type.
311304
*@boxRunTimeDoc@
@@ -324,20 +317,17 @@ def box(x: @name@): @boxed@ = @boxImpl@
324317
*/
325318
def unbox(x: java.lang.Object): @name@ = @unboxImpl@
326319
327-
/** The String representation of the scala.@name@ companion object.
328-
*/
320+
/** The String representation of the scala.@name@ companion object. */
329321
override def toString = "object scala.@name@"
330322
"""
331323

332324
def nonUnitCompanions = "" // todo
333325

334326
def cardinalCompanion = """
335-
/** The smallest value representable as a @name@.
336-
*/
327+
/** The smallest value representable as a @name@. */
337328
final val MinValue = @[email protected]_VALUE
338329
339-
/** The largest value representable as a @name@.
340-
*/
330+
/** The largest value representable as a @name@. */
341331
final val MaxValue = @[email protected]_VALUE
342332
"""
343333

@@ -372,18 +362,16 @@ class AnyVals extends AnyValReps with AnyValTemplates {
372362
object D extends AnyValNum("Double", Some("64-bit IEEE-754 floating point number"), "double")
373363
object Z extends AnyValRep("Boolean", None, "boolean") {
374364
def classLines = """
375-
/**
376-
* Negates a Boolean expression.
377-
*
378-
* - `!a` results in `false` if and only if `a` evaluates to `true` and
379-
* - `!a` results in `true` if and only if `a` evaluates to `false`.
380-
*
381-
* @return the negated expression
382-
*/
365+
/** Negates a Boolean expression.
366+
*
367+
* - `!a` results in `false` if and only if `a` evaluates to `true` and
368+
* - `!a` results in `true` if and only if `a` evaluates to `false`.
369+
*
370+
* @return the negated expression
371+
*/
383372
def unary_! : Boolean
384373
385-
/**
386-
* Compares two Boolean expressions and returns `true` if they evaluate to the same value.
374+
/** Compares two Boolean expressions and returns `true` if they evaluate to the same value.
387375
*
388376
* `a == b` returns `true` if and only if
389377
* - `a` and `b` are `true` or
@@ -400,8 +388,7 @@ def ==(x: Boolean): Boolean
400388
*/
401389
def !=(x: Boolean): Boolean
402390
403-
/**
404-
* Compares two Boolean expressions and returns `true` if one or both of them evaluate to true.
391+
/** Compares two Boolean expressions and returns `true` if one or both of them evaluate to true.
405392
*
406393
* `a || b` returns `true` if and only if
407394
* - `a` is `true` or
@@ -414,8 +401,7 @@ def !=(x: Boolean): Boolean
414401
*/
415402
def ||(x: Boolean): Boolean
416403
417-
/**
418-
* Compares two Boolean expressions and returns `true` if both of them evaluate to true.
404+
/** Compares two Boolean expressions and returns `true` if both of them evaluate to true.
419405
*
420406
* `a && b` returns `true` if and only if
421407
* - `a` and `b` are `true`.
@@ -430,8 +416,7 @@ def &&(x: Boolean): Boolean
430416
// def ||(x: => Boolean): Boolean
431417
// def &&(x: => Boolean): Boolean
432418
433-
/**
434-
* Compares two Boolean expressions and returns `true` if one or both of them evaluate to true.
419+
/** Compares two Boolean expressions and returns `true` if one or both of them evaluate to true.
435420
*
436421
* `a | b` returns `true` if and only if
437422
* - `a` is `true` or
@@ -442,8 +427,7 @@ def &&(x: Boolean): Boolean
442427
*/
443428
def |(x: Boolean): Boolean
444429
445-
/**
446-
* Compares two Boolean expressions and returns `true` if both of them evaluate to true.
430+
/** Compares two Boolean expressions and returns `true` if both of them evaluate to true.
447431
*
448432
* `a & b` returns `true` if and only if
449433
* - `a` and `b` are `true`.
@@ -452,8 +436,7 @@ def |(x: Boolean): Boolean
452436
*/
453437
def &(x: Boolean): Boolean
454438
455-
/**
456-
* Compares two Boolean expressions and returns `true` if they evaluate to a different value.
439+
/** Compares two Boolean expressions and returns `true` if they evaluate to a different value.
457440
*
458441
* `a ^ b` returns `true` if and only if
459442
* - `a` is `true` and `b` is `false` or
@@ -499,5 +482,3 @@ override def getClass(): Class[Boolean] = null
499482

500483
def make() = values map (x => (x.name, x.make()))
501484
}
502-
503-
object AnyVals extends AnyVals { }

src/compiler/scala/tools/cmd/gen/Codegen.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
package scala.tools.cmd
77
package gen
88

9-
import scala.language.postfixOps
10-
119
class Codegen(args: List[String]) extends {
1210
val parsed = CodegenSpec(args: _*)
13-
} with CodegenSpec with Instance { }
11+
} with CodegenSpec with Instance
1412

1513
object Codegen {
1614
def echo(msg: String) = Console println msg
@@ -31,7 +29,7 @@ object Codegen {
3129
val av = new AnyVals { }
3230

3331
av.make() foreach { case (name, code ) =>
34-
val file = out / (name + ".scala") toFile;
32+
val file = (out / (name + ".scala")).toFile
3533
echo("Writing: " + file)
3634
file writeAll code
3735
}

0 commit comments

Comments
 (0)