summaryrefslogtreecommitdiff
path: root/src/compiler/scala/reflect/reify
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2014-02-13 12:28:06 -0800
committerAdriaan Moors <adriaan.moors@typesafe.com>2014-02-13 18:53:06 -0800
commit33fc68171105bb8d884219381c220076c5651316 (patch)
treed09484d6b415d5877e6dde5a3ead189ec6952414 /src/compiler/scala/reflect/reify
parentc83e01d47d941265fa5415c0f29a884c904fdfa0 (diff)
downloadscala-33fc68171105bb8d884219381c220076c5651316.tar.gz
scala-33fc68171105bb8d884219381c220076c5651316.tar.bz2
scala-33fc68171105bb8d884219381c220076c5651316.zip
SI-8177 specializeSym must use memberInfo on high side
When determining whether member `symLo` of `tpLo` has a stronger type than member `symHi` of `tpHi`, should we use memberType or memberInfo? Well, memberType transforms (using `asSeenFrom`) `sym.tpe`, whereas memberInfo performs the same transform on `sym.info`. For term symbols, this ends up being the same thing (`sym.tpe == sym.info`). For type symbols, however, the `.info` of an abstract type member is defined by its bounds, whereas its `.tpe` is a `TypeRef` to that type symbol, so that `sym.tpe <:< sym.info`, but not the other way around. Thus, for the strongest (correct) result, we should use `memberType` on the low side. On the high side, we should use the result appropriate for the right side of the `<:<` above (`memberInfo`). I also optimized the method a little bit by avoiding calling memberType if the symbol on the high side isn't eligble (e.g., it's a class). PS: I had to add a workaround to reifyType, because we now dealias a little less eagerly, which means a type selection on refinement class symbols makes it to reify this broke the t8104 tests. I also had to update the run/t6992 test, which should now test the right thing. Tests should be commented and/or use sensible names. What is it testing? What is the expected outcome? We should not be left guessing.
Diffstat (limited to 'src/compiler/scala/reflect/reify')
-rw-r--r--src/compiler/scala/reflect/reify/codegen/GenSymbols.scala2
-rw-r--r--src/compiler/scala/reflect/reify/codegen/GenTypes.scala4
2 files changed, 4 insertions, 2 deletions
diff --git a/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala b/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala
index 3a97089d51..2965db17c6 100644
--- a/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala
+++ b/src/compiler/scala/reflect/reify/codegen/GenSymbols.scala
@@ -93,7 +93,7 @@ trait GenSymbols {
// todo. make sure that free methods and free local defs work correctly
if (sym.isExistential) reifySymDef(sym)
else if (sym.isTerm) reifyFreeTerm(Ident(sym))
- else reifyFreeType(Ident(sym))
+ else reifyFreeType(Ident(sym)) // TODO: reify refinement classes
}
}
diff --git a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala
index a90a3a338b..3e2acc28e5 100644
--- a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala
+++ b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala
@@ -55,7 +55,9 @@ trait GenTypes {
case tpe @ ConstantType(value) =>
mirrorFactoryCall(nme.ConstantType, reifyProduct(value))
case tpe @ TypeRef(pre, sym, args) =>
- reifyProduct(tpe)
+ // TODO: remove special case!!! for now, as we can't reify these symbols, let's hope dealias gets us out of this bind...
+ if (pre.typeSymbol.isAnonOrRefinementClass && (tpe ne tpe.dealias)) reifyType(tpe.dealias)
+ else reifyProduct(tpe)
case tpe @ TypeBounds(lo, hi) =>
reifyProduct(tpe)
case tpe @ NullaryMethodType(restpe) =>