From 427b82648422e4118c68f34e81c94deca3755deb Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Mon, 10 Feb 2014 13:43:30 -0800 Subject: 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. --- src/reflect/scala/reflect/internal/Types.scala | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/reflect') 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) -- cgit v1.2.3