diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2013-02-07 18:45:34 +0100 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2013-02-07 19:03:16 +0100 |
commit | 0d68a874e2158d9739abd3977ae0d9edd4a76e59 (patch) | |
tree | 00a45b678ef24b5258c4fa948d01076968461444 | |
parent | 3d318be51f8e8cdec314565920327486212f5020 (diff) | |
download | scala-0d68a874e2158d9739abd3977ae0d9edd4a76e59.tar.gz scala-0d68a874e2158d9739abd3977ae0d9edd4a76e59.tar.bz2 scala-0d68a874e2158d9739abd3977ae0d9edd4a76e59.zip |
SI-6113 typeOf now works for type lambdas
It's not a problem to have an abstract type symbol in a ground type tag
if that symbol is defined in the type being reified.
This mechanics was already built in for existentials, now we extend it to
include type params of poly types.
Credit goes to @katefree
-rw-r--r-- | src/compiler/scala/reflect/reify/codegen/GenTypes.scala | 3 | ||||
-rw-r--r-- | src/compiler/scala/reflect/reify/phases/Reify.scala | 5 | ||||
-rw-r--r-- | test/files/run/t6113.check | 1 | ||||
-rw-r--r-- | test/files/run/t6113.scala | 6 |
4 files changed, 12 insertions, 3 deletions
diff --git a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala index 7aa87dc2f8..bb7e1f9b56 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala @@ -69,8 +69,7 @@ trait GenTypes { def reificationIsConcrete: Boolean = state.reificationIsConcrete def spliceType(tpe: Type): Tree = { - val quantified = currentQuantified - if (tpe.isSpliceable && !(quantified contains tpe.typeSymbol)) { + if (tpe.isSpliceable && !(boundSymbolsInCallstack contains tpe.typeSymbol)) { if (reifyDebug) println("splicing " + tpe) val tagFlavor = if (concrete) tpnme.TypeTag.toString else tpnme.WeakTypeTag.toString diff --git a/src/compiler/scala/reflect/reify/phases/Reify.scala b/src/compiler/scala/reflect/reify/phases/Reify.scala index dc0028be38..8e13a45cdb 100644 --- a/src/compiler/scala/reflect/reify/phases/Reify.scala +++ b/src/compiler/scala/reflect/reify/phases/Reify.scala @@ -28,7 +28,10 @@ trait Reify extends GenSymbols finally currents = currents.tail } } - def currentQuantified = flatCollect(reifyStack.currents)({ case ExistentialType(quantified, _) => quantified }) + def boundSymbolsInCallstack = flatCollect(reifyStack.currents) { + case ExistentialType(quantified, _) => quantified + case PolyType(typeParams, _) => typeParams + } def current = reifyStack.currents.head def currents = reifyStack.currents diff --git a/test/files/run/t6113.check b/test/files/run/t6113.check new file mode 100644 index 0000000000..65fb3cd090 --- /dev/null +++ b/test/files/run/t6113.check @@ -0,0 +1 @@ +Foo[[X](Int, X)] diff --git a/test/files/run/t6113.scala b/test/files/run/t6113.scala new file mode 100644 index 0000000000..321cae86a3 --- /dev/null +++ b/test/files/run/t6113.scala @@ -0,0 +1,6 @@ +trait Foo[C[_]] + +object Test extends App { + import scala.reflect.runtime.universe._ + println(typeOf[Foo[({type l[X] = (Int, X)})#l]]) +}
\ No newline at end of file |