diff options
author | Eugene Vigdorchik <eugene.vigdorchik@gmail.com> | 2013-04-10 14:34:08 +0400 |
---|---|---|
committer | Eugene Vigdorchik <eugene.vigdorchik@gmail.com> | 2013-04-10 15:58:22 +0400 |
commit | 67c2d6df8141d77c7ac04aa6f97cbc6e53684473 (patch) | |
tree | 0606eb3d3331329e5f4b91e3a24fc458baf51298 | |
parent | fc65423d8d6a7548393d212e17c8563cf40bcfc0 (diff) | |
download | scala-67c2d6df8141d77c7ac04aa6f97cbc6e53684473.tar.gz scala-67c2d6df8141d77c7ac04aa6f97cbc6e53684473.tar.bz2 scala-67c2d6df8141d77c7ac04aa6f97cbc6e53684473.zip |
SI-6286 IllegalArgumentException handling specialized method.
Specialize assigns SpecialOverride info to a specialized method
even when there is a further specialization that should be forwarded
to.
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala | 37 | ||||
-rwxr-xr-x | test/files/pos/spec-t6286.scala | 10 |
2 files changed, 27 insertions, 20 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index a71920f787..07b1cb4206 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -976,27 +976,24 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { debuglog("specialized overload %s for %s in %s: %s".format(om, overriding.name.decode, pp(env), om.info)) typeEnv(om) = env addConcreteSpecMethod(overriding) - info(om) = ( - if (overriding.isDeferred) { // abstract override - debuglog("abstract override " + overriding.fullName + " with specialized " + om.fullName) - Forward(overriding) - } - else { - // if the override is a normalized member, 'om' gets the - // implementation from its original target, and adds the - // environment of the normalized member (that is, any - // specialized /method/ type parameter bindings) - val impl = info get overriding match { - case Some(NormalizedMember(target)) => - typeEnv(om) = env ++ typeEnv(overriding) - target - case _ => - overriding - } - info(overriding) = Forward(om setPos overriding.pos) - SpecialOverride(impl) + if (overriding.isDeferred) { // abstract override + debuglog("abstract override " + overriding.fullName + " with specialized " + om.fullName) + info(om) = Forward(overriding) + } + else { + // if the override is a normalized member, 'om' gets the + // implementation from its original target, and adds the + // environment of the normalized member (that is, any + // specialized /method/ type parameter bindings) + info get overriding match { + case Some(NormalizedMember(target)) => + typeEnv(om) = env ++ typeEnv(overriding) + info(om) = Forward(target) + case _ => + info(om) = SpecialOverride(overriding) } - ) + info(overriding) = Forward(om setPos overriding.pos) + } newOverload(overriding, om, env) ifDebug(afterSpecialize(assert( overridden.owner.info.decl(om.name) != NoSymbol, diff --git a/test/files/pos/spec-t6286.scala b/test/files/pos/spec-t6286.scala new file mode 100755 index 0000000000..4d87998ec6 --- /dev/null +++ b/test/files/pos/spec-t6286.scala @@ -0,0 +1,10 @@ +trait Foo[@specialized(Int) A] { + def fun[@specialized(Int) B](init: B)(f: (B, A) => B): B +} + +class Bar(values: Array[Int]) extends Foo[Int] { + def fun[@specialized(Int) C](init: C)(f: (C, Int) => C): C = { + val arr = values + f(init, arr(0)) + } +} |