Skip to content

Commit 0b1667b

Browse files
committed
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.
1 parent 46d6410 commit 0b1667b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/compiler/scala/reflect/reify/Taggers.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ abstract class Taggers {
3838

3939
def materializeTypeTag(universe: Tree, mirror: Tree, tpe: Type, concrete: Boolean): Tree = {
4040
val tagType = if (concrete) TypeTagClass else AbsTypeTagClass
41-
val unaffiliatedTagTpe = TypeRef(BaseUniverseClass.asTypeConstructor, tagType, List(tpe))
41+
// what we need here is to compose a type BaseUniverse # TypeTag[$tpe]
42+
// to look for an implicit that conforms to this type
43+
// that's why neither appliedType(tagType, List(tpe)) aka TypeRef(TypeTagsClass.thisType, tagType, List(tpe))
44+
// nor TypeRef(BaseUniverseClass.thisType, tagType, List(tpe)) won't fit here
45+
// scala> :type -v def foo: scala.reflect.base.Universe#TypeTag[Int] = ???
46+
// NullaryMethodType(TypeRef(pre = TypeRef(TypeSymbol(Universe)), TypeSymbol(TypeTag), args = List($tpe))))
47+
val unaffiliatedTagTpe = TypeRef(BaseUniverseClass.typeConstructor, tagType, List(tpe))
4248
val unaffiliatedTag = c.inferImplicitValue(unaffiliatedTagTpe, silent = true, withMacrosDisabled = true)
4349
unaffiliatedTag match {
4450
case success if !success.isEmpty =>

0 commit comments

Comments
 (0)