summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--src/compiler/scala/tools/nsc/settings/MutableSettings.scala21
-rw-r--r--src/compiler/scala/tools/nsc/settings/ScalaSettings.scala16
-rw-r--r--src/compiler/scala/tools/nsc/settings/Warnings.scala22
-rw-r--r--src/compiler/scala/tools/nsc/transform/Erasure.scala7
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Analyzer.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala2
-rw-r--r--src/library/scala/collection/parallel/ParIterableLike.scala2
-rw-r--r--src/library/scala/collection/parallel/ParSeqLike.scala1
-rw-r--r--src/library/scala/collection/parallel/package.scala72
-rw-r--r--src/reflect/scala/reflect/internal/Variances.scala7
-rw-r--r--src/reflect/scala/reflect/internal/tpe/TypeMaps.scala3
-rw-r--r--test/files/neg/t8072.check4
-rw-r--r--test/files/neg/t8072.scala6
-rw-r--r--test/files/neg/warn-unused-imports.check13
-rw-r--r--test/files/neg/warn-unused-imports.flags2
-rw-r--r--test/files/neg/warn-unused-privates.flags2
-rw-r--r--test/files/pos/t5165b/TestAnnotation_1.java11
-rw-r--r--test/files/pos/t5165b/TestObject_3.scala3
-rw-r--r--test/files/pos/t5165b/TestTrait_2.scala3
-rw-r--r--test/files/run/t5134.scala8
-rw-r--r--test/files/run/t5565.scala12
-rw-r--r--test/files/run/t7932.check3
-rw-r--r--test/files/run/t7932.scala11
-rw-r--r--test/junit/scala/tools/nsc/settings/SettingsTest.scala52
26 files changed, 210 insertions, 83 deletions
diff --git a/README.md b/README.md
index a273cfb544..fdc989228c 100644
--- a/README.md
+++ b/README.md
@@ -4,5 +4,5 @@ This is the repository for the [Scala Programming Language](http://www.scala-lan
- [Read about the development of the compiler and the standard library](http://docs.scala-lang.org/scala/);
- [Check our Jenkins status](https://scala-webapps.epfl.ch/jenkins/);
- [Download the latest nightly](https://scala-webapps.epfl.ch/jenkins/job/scala-nightly-main-master/ws/dists/latest/*zip*/latest.zip);
- - ... and contribute right here! Please, first read our [policy](http://docs.scala-lang.org/scala/pull-request-policy.html),
+ - ... and contribute right here! Please, first read our [policy](http://docs.scala-lang.org/scala/pull-request-policy.html), our [development guidelines](CONTRIBUTING.md),
and [sign the contributor's license agreement](http://typesafe.com/contribute/cla/scala).
diff --git a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala
index 0536be92cf..3590254128 100644
--- a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala
@@ -438,6 +438,17 @@ class MutableSettings(val errorFn: String => Unit)
override def tryToSetFromPropertyValue(s : String) { // used from ide
value = s.equalsIgnoreCase("true")
}
+ override def tryToSetColon(args: List[String]) = args match {
+ case Nil => tryToSet(Nil)
+ case List(x) =>
+ if (x.equalsIgnoreCase("true")) {
+ value = true
+ Some(Nil)
+ } else if (x.equalsIgnoreCase("false")) {
+ value = false
+ Some(Nil)
+ } else errorAndValue("'" + x + "' is not a valid choice for '" + name + "'", None)
+ }
}
/** A special setting for accumulating arguments like -Dfoo=bar. */
@@ -668,4 +679,14 @@ class MutableSettings(val errorFn: String => Unit)
else name + "[:phases]"
)
}
+
+ /** Internal use - syntax enhancements. */
+ protected class EnableSettings[T <: BooleanSetting](val s: T) {
+ def enablingIfNotSetByUser(toEnable: List[BooleanSetting]): s.type = s withPostSetHook (_ => toEnable foreach (sett => if (!sett.isSetByUser) sett.value = s.value))
+ def enabling(toEnable: List[BooleanSetting]): s.type = s withPostSetHook (_ => toEnable foreach (_.value = s.value))
+ def disabling(toDisable: List[BooleanSetting]): s.type = s withPostSetHook (_ => toDisable foreach (_.value = !s.value))
+ def andThen(f: s.T => Unit): s.type = s withPostSetHook (setting => f(setting.value))
+ }
+ import scala.language.implicitConversions
+ protected implicit def installEnableSettings[T <: BooleanSetting](s: T): EnableSettings[T] = new EnableSettings(s)
}
diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
index a385a31165..a643a08614 100644
--- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
@@ -20,7 +20,7 @@ trait ScalaSettings extends AbsScalaSettings
self: MutableSettings =>
/** Set of settings */
- protected lazy val allSettings = mutable.HashSet[Setting]()
+ protected[scala] lazy val allSettings = mutable.HashSet[Setting]()
/** Against my better judgment, giving in to martin here and allowing
* CLASSPATH to be used automatically. So for the user-specified part
@@ -47,14 +47,6 @@ trait ScalaSettings extends AbsScalaSettings
/** Is an info setting set? */
def isInfo = infoSettings exists (_.isSetByUser)
- /** Internal use - syntax enhancements. */
- private class EnableSettings[T <: BooleanSetting](val s: T) {
- def enabling(toEnable: List[BooleanSetting]): s.type = s withPostSetHook (_ => toEnable foreach (_.value = s.value))
- def disabling(toDisable: List[BooleanSetting]): s.type = s withPostSetHook (_ => toDisable foreach (_.value = !s.value))
- def andThen(f: s.T => Unit): s.type = s withPostSetHook (setting => f(setting.value))
- }
- private implicit def installEnableSettings[T <: BooleanSetting](s: T) = new EnableSettings(s)
-
/** Disable a setting */
def disable(s: Setting) = allSettings -= s
@@ -216,10 +208,10 @@ trait ScalaSettings extends AbsScalaSettings
/** Groups of Settings.
*/
- val future = BooleanSetting("-Xfuture", "Turn on future language features.") enabling futureSettings
- val optimise = BooleanSetting("-optimise", "Generates faster bytecode by applying optimisations to the program") withAbbreviation "-optimize" enabling optimiseSettings
+ val future = BooleanSetting("-Xfuture", "Turn on future language features.") enablingIfNotSetByUser futureSettings
+ val optimise = BooleanSetting("-optimise", "Generates faster bytecode by applying optimisations to the program") withAbbreviation "-optimize" enablingIfNotSetByUser optimiseSettings
val nooptimise = BooleanSetting("-Ynooptimise", "Clears all the flags set by -optimise. Useful for testing optimizations in isolation.") withAbbreviation "-Ynooptimize" disabling optimise::optimiseSettings
- val Xexperimental = BooleanSetting("-Xexperimental", "Enable experimental extensions.") enabling experimentalSettings
+ val Xexperimental = BooleanSetting("-Xexperimental", "Enable experimental extensions.") enablingIfNotSetByUser experimentalSettings
/**
* Settings motivated by GenBCode
diff --git a/src/compiler/scala/tools/nsc/settings/Warnings.scala b/src/compiler/scala/tools/nsc/settings/Warnings.scala
index 791d44153c..1509ad13b8 100644
--- a/src/compiler/scala/tools/nsc/settings/Warnings.scala
+++ b/src/compiler/scala/tools/nsc/settings/Warnings.scala
@@ -7,6 +7,8 @@ package scala.tools
package nsc
package settings
+import language.existentials
+
/** Settings influencing the printing of warnings.
*/
trait Warnings {
@@ -30,21 +32,10 @@ trait Warnings {
warnNullaryUnit,
warnAdaptedArgs,
warnInferAny
+ // warnUnused SI-7712, SI-7707 warnUnused not quite ready for prime-time
+ // warnUnusedImport currently considered too noisy for general use
)
- // Warning groups.
- val lint = (
- BooleanSetting("-Xlint", "Enable recommended additional warnings.")
- withPostSetHook (_ => lintWarnings foreach (_.value = true))
- )
-
- /*val warnEverything = */ (
- BooleanSetting("-Ywarn-all", "Enable all -Y warnings.")
- withPostSetHook { _ =>
- lint.value = true
- allWarnings foreach (_.value = true)
- }
- )
private lazy val warnSelectNullable = BooleanSetting("-Xcheck-null", "This option is obsolete and does nothing.")
// Individual warnings.
@@ -56,6 +47,11 @@ trait Warnings {
val warnInaccessible = BooleanSetting ("-Ywarn-inaccessible", "Warn about inaccessible types in method signatures.")
val warnNullaryOverride = BooleanSetting ("-Ywarn-nullary-override", "Warn when non-nullary overrides nullary, e.g. `def foo()` over `def foo`.")
val warnInferAny = BooleanSetting ("-Ywarn-infer-any", "Warn when a type argument is inferred to be `Any`.")
+ val warnUnused = BooleanSetting ("-Ywarn-unused", "Warn when local and private vals, vars, defs, and types are are unused")
+ val warnUnusedImport = BooleanSetting ("-Ywarn-unused-import", "Warn when imports are unused")
+
+ // Warning groups.
+ val lint = BooleanSetting("-Xlint", "Enable recommended additional warnings.") enablingIfNotSetByUser lintWarnings
// Backward compatibility.
@deprecated("Use fatalWarnings", "2.11.0") def Xwarnfatal = fatalWarnings // used by sbt
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala
index eba2e1399d..bd2f6f0018 100644
--- a/src/compiler/scala/tools/nsc/transform/Erasure.scala
+++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala
@@ -238,8 +238,11 @@ abstract class Erasure extends AddInterfaces
if (!(AnyRefTpe <:< bounds.hi)) "+" + boxedSig(bounds.hi)
else if (!(bounds.lo <:< NullTpe)) "-" + boxedSig(bounds.lo)
else "*"
- } else {
- boxedSig(tp)
+ } else tp match {
+ case PolyType(_, res) =>
+ "*" // SI-7932
+ case _ =>
+ boxedSig(tp)
}
def classSig = {
val preRebound = pre.baseType(sym.owner) // #2585
diff --git a/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala b/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala
index 5c02516c47..323fe1c171 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala
@@ -102,7 +102,9 @@ trait Analyzer extends AnyRef
unit.body = typer.typed(unit.body)
if (global.settings.Yrangepos && !global.reporter.hasErrors) global.validatePositions(unit.body)
for (workItem <- unit.toCheck) workItem()
- if (settings.lint)
+ if (settings.warnUnusedImport)
+ warnUnusedImports(unit)
+ if (settings.warnUnused)
typer checkUnused unit
}
finally {
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 6e9e16ffc9..98ee4ad94d 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -1207,7 +1207,7 @@ trait Contexts { self: Analyzer =>
trait ImportContext extends Context {
private val impInfo: ImportInfo = {
val info = new ImportInfo(tree.asInstanceOf[Import], outerDepth)
- if (settings.lint && !isRootImport) // excludes java.lang/scala/Predef imports
+ if (settings.warnUnusedImport && !isRootImport) // excludes java.lang/scala/Predef imports
allImportInfos(unit) ::= info
info
}
@@ -1316,7 +1316,7 @@ trait Contexts { self: Analyzer =>
if (result == NoSymbol)
selectors = selectors.tail
}
- if (settings.lint && selectors.nonEmpty && result != NoSymbol && pos != NoPosition)
+ if (settings.warnUnusedImport && selectors.nonEmpty && result != NoSymbol && pos != NoPosition)
recordUsage(current, result)
// Harden against the fallout from bugs like SI-6745
diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
index ca960d7b11..60346e7be1 100644
--- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
@@ -518,8 +518,6 @@ trait TypeDiagnostics {
}
def apply(unit: CompilationUnit) = {
- warnUnusedImports(unit)
-
val p = new UnusedPrivates
p traverse unit.body
val unused = p.unusedTerms
diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala
index 6ab76bce89..445edd23cb 100644
--- a/src/library/scala/collection/parallel/ParIterableLike.scala
+++ b/src/library/scala/collection/parallel/ParIterableLike.scala
@@ -29,6 +29,8 @@ import scala.annotation.unchecked.uncheckedVariance
import scala.annotation.unchecked.uncheckedStable
import scala.language.{ higherKinds, implicitConversions }
+import scala.collection.parallel.ParallelCollectionImplicits._
+
/** A template trait for parallel collections of type `ParIterable[T]`.
*
diff --git a/src/library/scala/collection/parallel/ParSeqLike.scala b/src/library/scala/collection/parallel/ParSeqLike.scala
index ca21f24534..0b6fec364e 100644
--- a/src/library/scala/collection/parallel/ParSeqLike.scala
+++ b/src/library/scala/collection/parallel/ParSeqLike.scala
@@ -16,6 +16,7 @@ import scala.collection.generic.CanBuildFrom
import scala.collection.generic.CanCombineFrom
import scala.collection.generic.VolatileAbort
+import scala.collection.parallel.ParallelCollectionImplicits._
/** A template trait for sequences of type `ParSeq[T]`, representing
* parallel sequences with element type `T`.
diff --git a/src/library/scala/collection/parallel/package.scala b/src/library/scala/collection/parallel/package.scala
index 923e21e5a7..91c54fa8f1 100644
--- a/src/library/scala/collection/parallel/package.scala
+++ b/src/library/scala/collection/parallel/package.scala
@@ -53,43 +53,52 @@ package object parallel {
c
}
- /* implicit conversions */
-
- implicit def factory2ops[From, Elem, To](bf: CanBuildFrom[From, Elem, To]) = new FactoryOps[From, Elem, To] {
- def isParallel = bf.isInstanceOf[Parallel]
- def asParallel = bf.asInstanceOf[CanCombineFrom[From, Elem, To]]
- def ifParallel[R](isbody: CanCombineFrom[From, Elem, To] => R) = new Otherwise[R] {
- def otherwise(notbody: => R) = if (isParallel) isbody(asParallel) else notbody
- }
- }
- implicit def traversable2ops[T](t: scala.collection.GenTraversableOnce[T]) = new TraversableOps[T] {
- def isParallel = t.isInstanceOf[Parallel]
- def isParIterable = t.isInstanceOf[ParIterable[_]]
- def asParIterable = t.asInstanceOf[ParIterable[T]]
- def isParSeq = t.isInstanceOf[ParSeq[_]]
- def asParSeq = t.asInstanceOf[ParSeq[T]]
- def ifParSeq[R](isbody: ParSeq[T] => R) = new Otherwise[R] {
- def otherwise(notbody: => R) = if (isParallel) isbody(asParSeq) else notbody
- }
- def toParArray = if (t.isInstanceOf[ParArray[_]]) t.asInstanceOf[ParArray[T]] else {
- val it = t.toIterator
- val cb = mutable.ParArrayCombiner[T]()
- while (it.hasNext) cb += it.next
- cb.result
- }
- }
- implicit def throwable2ops(self: Throwable) = new ThrowableOps {
- def alongWith(that: Throwable) = (self, that) match {
- case (self: CompositeThrowable, that: CompositeThrowable) => new CompositeThrowable(self.throwables ++ that.throwables)
- case (self: CompositeThrowable, _) => new CompositeThrowable(self.throwables + that)
- case (_, that: CompositeThrowable) => new CompositeThrowable(that.throwables + self)
- case _ => new CompositeThrowable(Set(self, that))
+ /** Adds toParArray method to collection classes. */
+ implicit class CollectionsHaveToParArray[C, T](c: C)(implicit asGto: C => scala.collection.GenTraversableOnce[T]) {
+ def toParArray = {
+ val t = asGto(c)
+ if (t.isInstanceOf[ParArray[_]]) t.asInstanceOf[ParArray[T]]
+ else {
+ val it = t.toIterator
+ val cb = mutable.ParArrayCombiner[T]()
+ while (it.hasNext) cb += it.next
+ cb.result
+ }
}
}
}
package parallel {
+ /** Implicit conversions used in the implementation of parallel collections. */
+ private[collection] object ParallelCollectionImplicits {
+ implicit def factory2ops[From, Elem, To](bf: CanBuildFrom[From, Elem, To]) = new FactoryOps[From, Elem, To] {
+ def isParallel = bf.isInstanceOf[Parallel]
+ def asParallel = bf.asInstanceOf[CanCombineFrom[From, Elem, To]]
+ def ifParallel[R](isbody: CanCombineFrom[From, Elem, To] => R) = new Otherwise[R] {
+ def otherwise(notbody: => R) = if (isParallel) isbody(asParallel) else notbody
+ }
+ }
+ implicit def traversable2ops[T](t: scala.collection.GenTraversableOnce[T]) = new TraversableOps[T] {
+ def isParallel = t.isInstanceOf[Parallel]
+ def isParIterable = t.isInstanceOf[ParIterable[_]]
+ def asParIterable = t.asInstanceOf[ParIterable[T]]
+ def isParSeq = t.isInstanceOf[ParSeq[_]]
+ def asParSeq = t.asInstanceOf[ParSeq[T]]
+ def ifParSeq[R](isbody: ParSeq[T] => R) = new Otherwise[R] {
+ def otherwise(notbody: => R) = if (isParallel) isbody(asParSeq) else notbody
+ }
+ }
+ implicit def throwable2ops(self: Throwable) = new ThrowableOps {
+ def alongWith(that: Throwable) = (self, that) match {
+ case (self: CompositeThrowable, that: CompositeThrowable) => new CompositeThrowable(self.throwables ++ that.throwables)
+ case (self: CompositeThrowable, _) => new CompositeThrowable(self.throwables + that)
+ case (_, that: CompositeThrowable) => new CompositeThrowable(that.throwables + self)
+ case _ => new CompositeThrowable(Set(self, that))
+ }
+ }
+ }
+
trait FactoryOps[From, Elem, To] {
trait Otherwise[R] {
def otherwise(notbody: => R): R
@@ -111,7 +120,6 @@ package parallel {
def isParSeq: Boolean
def asParSeq: ParSeq[T]
def ifParSeq[R](isbody: ParSeq[T] => R): Otherwise[R]
- def toParArray: ParArray[T]
}
@deprecated("This trait will be removed.", "2.11.0")
diff --git a/src/reflect/scala/reflect/internal/Variances.scala b/src/reflect/scala/reflect/internal/Variances.scala
index ca43fdcb63..3bcfed7d34 100644
--- a/src/reflect/scala/reflect/internal/Variances.scala
+++ b/src/reflect/scala/reflect/internal/Variances.scala
@@ -65,10 +65,11 @@ trait Variances {
* The search proceeds from `base` to the owner of `tvar`.
* Initially the state is covariant, but it might change along the search.
*
- * An alias which does not override anything is treated as Bivariant;
+ * A local alias type is treated as Bivariant;
* this is OK because we always expand aliases for variance checking.
- * However if it does override a type in a base class, we must assume Invariant
- * because there may be references to the type parameter that are not checked.
+ * However, for an alias which might be externally visible, we must assume Invariant,
+ * because there may be references to the type parameter that are not checked,
+ * leading to unsoundness (see SI-6566).
*/
def relativeVariance(tvar: Symbol): Variance = {
def nextVariance(sym: Symbol, v: Variance): Variance = (
diff --git a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala
index 6d83032c2d..f06420de96 100644
--- a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala
+++ b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala
@@ -667,7 +667,8 @@ private[internal] trait TypeMaps {
/** A base class to compute all substitutions */
abstract class SubstMap[T](from: List[Symbol], to: List[T]) extends TypeMap {
- assert(sameLength(from, to), "Unsound substitution from "+ from +" to "+ to)
+ // OPT this check was 2-3% of some profiles, demoted to -Xdev
+ if (isDeveloper) assert(sameLength(from, to), "Unsound substitution from "+ from +" to "+ to)
/** Are `sym` and `sym1` the same? Can be tuned by subclasses. */
protected def matches(sym: Symbol, sym1: Symbol): Boolean = sym eq sym1
diff --git a/test/files/neg/t8072.check b/test/files/neg/t8072.check
new file mode 100644
index 0000000000..9267010135
--- /dev/null
+++ b/test/files/neg/t8072.check
@@ -0,0 +1,4 @@
+t8072.scala:4: error: value ifParSeq is not a member of List[Int]
+ val y = x.ifParSeq[Int](throw new Exception).otherwise(0) // Shouldn't compile
+ ^
+one error found
diff --git a/test/files/neg/t8072.scala b/test/files/neg/t8072.scala
new file mode 100644
index 0000000000..2c8213e34a
--- /dev/null
+++ b/test/files/neg/t8072.scala
@@ -0,0 +1,6 @@
+class NoIfParSeq {
+ import collection.parallel._
+ val x = List(1,2)
+ val y = x.ifParSeq[Int](throw new Exception).otherwise(0) // Shouldn't compile
+ val z = x.toParArray
+} \ No newline at end of file
diff --git a/test/files/neg/warn-unused-imports.check b/test/files/neg/warn-unused-imports.check
index 1b938f4fd7..36c6dd03c3 100644
--- a/test/files/neg/warn-unused-imports.check
+++ b/test/files/neg/warn-unused-imports.check
@@ -1,11 +1,3 @@
-warn-unused-imports.scala:7: warning: it is not recommended to define classes/objects inside of package objects.
-If possible, define class A in package p1 instead.
- class A
- ^
-warn-unused-imports.scala:13: warning: it is not recommended to define classes/objects inside of package objects.
-If possible, define class A in package p2 instead.
- class A
- ^
warn-unused-imports.scala:57: warning: Unused import
import p1.A // warn
^
@@ -36,9 +28,6 @@ warn-unused-imports.scala:98: warning: Unused import
warn-unused-imports.scala:118: warning: Unused import
import p1.A // warn
^
-warn-unused-imports.scala:99: warning: local trait Warn is never used
- trait Warn { // warn about unused local trait for good measure
- ^
error: No warnings can be incurred under -Xfatal-warnings.
-13 warnings found
+10 warnings found
one error found
diff --git a/test/files/neg/warn-unused-imports.flags b/test/files/neg/warn-unused-imports.flags
index 954eaba352..24db705df1 100644
--- a/test/files/neg/warn-unused-imports.flags
+++ b/test/files/neg/warn-unused-imports.flags
@@ -1 +1 @@
--Xfatal-warnings -Xlint
+-Xfatal-warnings -Ywarn-unused-import
diff --git a/test/files/neg/warn-unused-privates.flags b/test/files/neg/warn-unused-privates.flags
index 7949c2afa2..25474aefb3 100644
--- a/test/files/neg/warn-unused-privates.flags
+++ b/test/files/neg/warn-unused-privates.flags
@@ -1 +1 @@
--Xlint -Xfatal-warnings
+-Ywarn-unused -Xfatal-warnings
diff --git a/test/files/pos/t5165b/TestAnnotation_1.java b/test/files/pos/t5165b/TestAnnotation_1.java
new file mode 100644
index 0000000000..02eb3f9d4c
--- /dev/null
+++ b/test/files/pos/t5165b/TestAnnotation_1.java
@@ -0,0 +1,11 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface TestAnnotation_1 {
+ public enum TestEnumOne { A, B }
+ public enum TestEnumTwo { C, D }
+
+ public TestEnumOne one();
+ public TestEnumTwo two();
+ public String strVal();
+}
diff --git a/test/files/pos/t5165b/TestObject_3.scala b/test/files/pos/t5165b/TestObject_3.scala
new file mode 100644
index 0000000000..eaf244e9d0
--- /dev/null
+++ b/test/files/pos/t5165b/TestObject_3.scala
@@ -0,0 +1,3 @@
+
+object TestObject extends TestTrait
+
diff --git a/test/files/pos/t5165b/TestTrait_2.scala b/test/files/pos/t5165b/TestTrait_2.scala
new file mode 100644
index 0000000000..ab4facebcd
--- /dev/null
+++ b/test/files/pos/t5165b/TestTrait_2.scala
@@ -0,0 +1,3 @@
+
+@TestAnnotation_1(one=TestAnnotation_1.TestEnumOne.A, two=TestAnnotation_1.TestEnumTwo.C, strVal="something")
+trait TestTrait
diff --git a/test/files/run/t5134.scala b/test/files/run/t5134.scala
new file mode 100644
index 0000000000..384442fda2
--- /dev/null
+++ b/test/files/run/t5134.scala
@@ -0,0 +1,8 @@
+import language._
+
+object Test extends App {
+ def b = new AnyRef {
+ def a= ()
+ }
+ b.a match { case _ => () }
+}
diff --git a/test/files/run/t5565.scala b/test/files/run/t5565.scala
new file mode 100644
index 0000000000..9ced87ca21
--- /dev/null
+++ b/test/files/run/t5565.scala
@@ -0,0 +1,12 @@
+import scala.language.reflectiveCalls
+import scala.language.implicitConversions
+
+object Test extends App {
+ implicit def doubleWithApproxEquals(d: Double) = new {
+ def ~==(v: Double, margin: Double = 0.001): Boolean =
+ math.abs(d - v) < margin
+ }
+
+ assert(math.abs(-4.0) ~== (4.0, 0.001))
+ assert(math.abs(-4.0) ~== 4.0)
+}
diff --git a/test/files/run/t7932.check b/test/files/run/t7932.check
new file mode 100644
index 0000000000..13d64f1d3c
--- /dev/null
+++ b/test/files/run/t7932.check
@@ -0,0 +1,3 @@
+warning: there were 1 feature warning(s); re-run with -feature for details
+public Category<?> C.category()
+public Category<scala.Tuple2> C.category1()
diff --git a/test/files/run/t7932.scala b/test/files/run/t7932.scala
new file mode 100644
index 0000000000..8743abff88
--- /dev/null
+++ b/test/files/run/t7932.scala
@@ -0,0 +1,11 @@
+class Category[M[_, _]]
+trait M[F] {
+ type X[a, b] = F
+ def category: Category[X] = null
+ def category1: Category[Tuple2] = null
+}
+abstract class C extends M[Float]
+object Test extends App {
+ val ms = classOf[C].getMethods.filter(_.getName.startsWith("category"))
+ println(ms.map(_.toGenericString).sorted.mkString("\n"))
+}
diff --git a/test/junit/scala/tools/nsc/settings/SettingsTest.scala b/test/junit/scala/tools/nsc/settings/SettingsTest.scala
new file mode 100644
index 0000000000..e4b5ecc7c3
--- /dev/null
+++ b/test/junit/scala/tools/nsc/settings/SettingsTest.scala
@@ -0,0 +1,52 @@
+package scala.tools.nsc
+package settings
+
+import org.junit.Assert._
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import scala.tools.testing.AssertUtil.assertThrows
+
+@RunWith(classOf[JUnit4])
+class SettingsTest {
+ @Test def booleanSettingColon() {
+ def check(args: String*): MutableSettings#BooleanSetting = {
+ val s = new MutableSettings(msg => throw new IllegalArgumentException(msg))
+ val b1 = new s.BooleanSetting("-Ytest-setting", "")
+ s.allSettings += b1
+ val (ok, residual) = s.processArguments(args.toList, processAll = true)
+ assert(residual.isEmpty)
+ b1
+ }
+ assertTrue(check("-Ytest-setting").value)
+ assertTrue(check("-Ytest-setting:true").value)
+ assertTrue(check("-Ytest-setting:TRUE").value)
+ assertFalse(check("-Ytest-setting:false").value)
+ assertFalse(check("-Ytest-setting:FALSE").value)
+ assertThrows[IllegalArgumentException](check("-Ytest-setting:rubbish"))
+ }
+
+ @Test def userSettingsHavePredecenceOverOptimize() {
+ def check(args: String*): MutableSettings#BooleanSetting = {
+ val s = new MutableSettings(msg => throw new IllegalArgumentException(msg))
+ val (ok, residual) = s.processArguments(args.toList, processAll = true)
+ assert(residual.isEmpty)
+ s.inline // among -optimize
+ }
+ assertTrue(check("-optimise").value)
+ assertFalse(check("-optimise", "-Yinline:false").value)
+ assertFalse(check("-Yinline:false", "-optimise").value)
+ }
+
+ @Test def userSettingsHavePredecenceOverLint() {
+ def check(args: String*): MutableSettings#BooleanSetting = {
+ val s = new MutableSettings(msg => throw new IllegalArgumentException(msg))
+ val (ok, residual) = s.processArguments(args.toList, processAll = true)
+ assert(residual.isEmpty)
+ s.warnAdaptedArgs // among Xlint
+ }
+ assertTrue(check("-Xlint").value)
+ assertFalse(check("-Xlint", "-Ywarn-adapted-args:false").value)
+ assertFalse(check("-Ywarn-adapted-args:false", "-Xlint").value)
+ }
+}