Permalink
Browse files

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
  • Loading branch information...
xeno-by committed Feb 7, 2013
1 parent 3d318be commit 0d68a874e2158d9739abd3977ae0d9edd4a76e59
@@ -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
@@ -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
@@ -0,0 +1 @@
+Foo[[X](Int, X)]
@@ -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]])
+}

2 comments on commit 0d68a87

Job pr-checkin-per-commit failed for 0d68a87 (results):


Took 9 s.
sad kitty
to rebuild, comment "PLS REBUILD/pr-checkin-per-commit@0d68a874e2158d9739abd3977ae0d9edd4a76e59"on PR #2112

Job pr-rangepos-per-commit failed for 0d68a87 (results):


Took 9 s.
sad kitty
to rebuild, comment "PLS REBUILD/pr-rangepos-per-commit@0d68a874e2158d9739abd3977ae0d9edd4a76e59"on PR #2112

Please sign in to comment.