summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-07-20 12:28:58 +0200
committerEugene Burmako <xeno.by@gmail.com>2012-07-20 12:28:58 +0200
commit0b1667b85675ef321587252c12878fc1b52888dd (patch)
treed20ad36d86232ffabc9ba7af649b01f0af21f8b5 /src/compiler
parent46d6410071a333d665ee3a41565d0d3432f47669 (diff)
downloadscala-0b1667b85675ef321587252c12878fc1b52888dd.tar.gz
scala-0b1667b85675ef321587252c12878fc1b52888dd.tar.bz2
scala-0b1667b85675ef321587252c12878fc1b52888dd.zip
an improvement based on Adriaan's comment
""" why use asTypeConstructor for a prefix? shouldn't that be BaseUniverseClass.thisType? also, why does the prefix need to be changed at all? I'm sure there's a valid reason, but it would be good to document it. if you don't need to change the prefix, use appliedType(tagType.typeConstructor, List(tpe)) """ Because we need to look for an implicit of type base.Universe # TypeTag[$tpe]. I figured out that this is exactly the internal representation of that type.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/reflect/reify/Taggers.scala8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/compiler/scala/reflect/reify/Taggers.scala b/src/compiler/scala/reflect/reify/Taggers.scala
index 576576bc6f..4e30d0acf8 100644
--- a/src/compiler/scala/reflect/reify/Taggers.scala
+++ b/src/compiler/scala/reflect/reify/Taggers.scala
@@ -38,7 +38,13 @@ abstract class Taggers {
def materializeTypeTag(universe: Tree, mirror: Tree, tpe: Type, concrete: Boolean): Tree = {
val tagType = if (concrete) TypeTagClass else AbsTypeTagClass
- val unaffiliatedTagTpe = TypeRef(BaseUniverseClass.asTypeConstructor, tagType, List(tpe))
+ // what we need here is to compose a type BaseUniverse # TypeTag[$tpe]
+ // to look for an implicit that conforms to this type
+ // that's why neither appliedType(tagType, List(tpe)) aka TypeRef(TypeTagsClass.thisType, tagType, List(tpe))
+ // nor TypeRef(BaseUniverseClass.thisType, tagType, List(tpe)) won't fit here
+ // scala> :type -v def foo: scala.reflect.base.Universe#TypeTag[Int] = ???
+ // NullaryMethodType(TypeRef(pre = TypeRef(TypeSymbol(Universe)), TypeSymbol(TypeTag), args = List($tpe))))
+ val unaffiliatedTagTpe = TypeRef(BaseUniverseClass.typeConstructor, tagType, List(tpe))
val unaffiliatedTag = c.inferImplicitValue(unaffiliatedTagTpe, silent = true, withMacrosDisabled = true)
unaffiliatedTag match {
case success if !success.isEmpty =>