diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-02-10 13:43:30 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-02-12 15:36:31 -0800 |
commit | 427b82648422e4118c68f34e81c94deca3755deb (patch) | |
tree | eff3dbe39b6d04feabfc44ba07aa3cada5a7a2ae /src/reflect | |
parent | 7ea7a3b89b2a597f7aa22eefe39e3bae7244882f (diff) | |
download | scala-427b82648422e4118c68f34e81c94deca3755deb.tar.gz scala-427b82648422e4118c68f34e81c94deca3755deb.tar.bz2 scala-427b82648422e4118c68f34e81c94deca3755deb.zip |
SI-8177 refine embeddedSymbols
We look for any prefix that has a refinement class for a type symbol.
This includes ThisTypes, which were not considered before.
pos/t8177g.scala, neg/t0764*scala now compile, as they should
Additional test cases contributed by Jason & Paul.
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/internal/Types.scala | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 0ef5d60a10..218ad28a03 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -2051,10 +2051,16 @@ trait Types // Return the symbol named `name` that's "embedded" in tp // This is the case if `tp` is a `T{...; type/val $name ; ...}`, // or a singleton type with such an underlying type. - private def embeddedSymbol(tp: Type, name: Name): Symbol = tp.widen match { - case RefinedType(_, decls) => decls lookup name - case _ => NoSymbol - } + private def embeddedSymbol(tp: Type, name: Name): Symbol = + // normalize to flatten nested RefinedTypes + // don't check whether tp is a RefinedType -- it may be a ThisType of one, for example + // TODO: check the resulting symbol is owned by the refinement class? likely an invariant... + if (tp.typeSymbol.isRefinementClass) tp.normalize.decls lookup name + else { + debuglog(s"no embedded symbol $name found in ${showRaw(tp)} --> ${tp.normalize.decls lookup name}") + NoSymbol + } + trait AbstractTypeRef extends NonClassTypeRef { require(sym.isAbstractType, sym) |