summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala10
-rw-r--r--test/files/pos/spec-doubledef.scala5
2 files changed, 14 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
index c624f85f5a..ceb390165e 100644
--- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
+++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
@@ -598,7 +598,15 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
private def normalizeMember(owner: Symbol, sym: Symbol, outerEnv: TypeEnv): List[Symbol] = {
if (settings.debug.value) log("normalizeMember: " + sym.fullName)
if (sym.isMethod && !atPhase(currentRun.typerPhase)(sym.typeParams.isEmpty)) {
- val (stps, tps) = splitParams(sym.info.typeParams)
+ var (stps, tps) = splitParams(sym.info.typeParams)
+ val unusedStvars = stps -- specializedTypeVars(sym.info).toList
+ if (unusedStvars.nonEmpty && currentRun.compiles(sym)) {
+ reporter.warning(sym.pos, "%s %s unused or used in non-specializable positions."
+ .format(unusedStvars.mkString("", ", ", ""), if (unusedStvars.length == 1) "is" else "are"))
+ unusedStvars foreach (_.removeAnnotation(SpecializedClass))
+ stps = stps -- unusedStvars
+ tps = tps ::: unusedStvars
+ }
val res = sym :: (for (env <- specializations(stps) if needsSpecialization(env, sym)) yield {
val keys = env.keysIterator.toList;
val vals = env.valuesIterator.toList
diff --git a/test/files/pos/spec-doubledef.scala b/test/files/pos/spec-doubledef.scala
index e296a17c78..014f683065 100644
--- a/test/files/pos/spec-doubledef.scala
+++ b/test/files/pos/spec-doubledef.scala
@@ -1,3 +1,8 @@
+object Test {
+ def fn[@specialized T, @specialized U](t : T => Int, u : U => Int) : T =
+ null.asInstanceOf[T]
+}
+
trait A[@specialized(Int) T] {
var value: T
def getWith[@specialized(Int) Z](f: T => Z) = f(value)