From 72503126d9c29ff029c4c9537234e1fb1d7a0130 Mon Sep 17 00:00:00 2001 From: Uladzimir Abramchuk Date: Fri, 15 Feb 2013 17:19:21 +0300 Subject: SI-6386 typed existential type tree's original now have tpe set Tree reification fails for ExistentialTypeTree. The reason is that the tree passed for reification (see reifyTree at GetTrees.scala) must have not null tpe (see reifyBoundType at GenTrees.scala), which is not true in the case of ExistentialTypeTree. Why is it so? The tree passed to reifyTree was obtained in the reshape phase of reificationusing using original TypeTrees that reporesent pre- typer representation of a type. The problem is that original's tpe for ExistentialTypeTree is not set. So the solution to the issue is to create ExistentialTypeTree's original in a such way that is has actual tpe set. --- test/files/pos/t6386.scala | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 test/files/pos/t6386.scala (limited to 'test/files/pos') diff --git a/test/files/pos/t6386.scala b/test/files/pos/t6386.scala new file mode 100644 index 0000000000..85098a78f0 --- /dev/null +++ b/test/files/pos/t6386.scala @@ -0,0 +1,5 @@ +import scala.reflect.runtime.universe._ + +object Test extends App { + reify(manifest[Some[_]]) +} \ No newline at end of file -- cgit v1.2.3 From 67c2d6df8141d77c7ac04aa6f97cbc6e53684473 Mon Sep 17 00:00:00 2001 From: Eugene Vigdorchik Date: Wed, 10 Apr 2013 14:34:08 +0400 Subject: 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. --- .../tools/nsc/transform/SpecializeTypes.scala | 37 ++++++++++------------ test/files/pos/spec-t6286.scala | 10 ++++++ 2 files changed, 27 insertions(+), 20 deletions(-) create mode 100755 test/files/pos/spec-t6286.scala (limited to 'test/files/pos') 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)) + } +} -- cgit v1.2.3