@@ -153,21 +153,23 @@ trait GenTrees {
153153 else mirrorCall(nme.Ident , reify(name))
154154
155155 case Select (qual, name) =>
156- if (sym == NoSymbol || sym.name == name)
157- reifyProduct(tree)
158- else
159- reifyProduct(Select (qual, sym.name))
156+ if (qual.symbol != null && qual.symbol.isPackage) {
157+ mirrorBuildCall(nme.Ident , reify(sym))
158+ } else {
159+ val effectiveName = if (sym != null && sym != NoSymbol ) sym.name else name
160+ reifyProduct(Select (qual, effectiveName))
161+ }
160162
161163 case _ =>
162164 throw new Error (" internal error: %s (%s, %s) is not supported" .format(tree, tree.productPrefix, tree.getClass))
163165 }
164166 }
165167
166- private def reifyBoundType (tree : Tree ): Tree = {
168+ private def reifyBoundType (tree : RefTree ): Tree = {
167169 val sym = tree.symbol
168170 val tpe = tree.tpe
169171
170- def reifyBoundType (tree : Tree ): Tree = {
172+ def reifyBoundType (tree : RefTree ): Tree = {
171173 assert(tpe != null , " unexpected: bound type that doesn't have a tpe: " + showRaw(tree))
172174
173175 // if a symbol or a type of the scrutinee are local to reifee
@@ -196,13 +198,19 @@ trait GenTrees {
196198 mirrorBuildCall(nme.TypeTree , spliced)
197199 }
198200 }
199- else if (sym.isLocatable) {
200- if (reifyDebug) println(" tpe is locatable: reify as Ident(%s)" .format(sym))
201- mirrorBuildCall(nme.Ident , reify(sym))
202- }
203- else {
204- if (reifyDebug) println(" tpe is not locatable: reify as TypeTree(%s)" .format(tpe))
205- mirrorBuildCall(nme.TypeTree , reify(tpe))
201+ else tree match {
202+ case Select (qual, name) if ! qual.symbol.isPackage =>
203+ if (reifyDebug) println(s " reifying Select( $qual, $name) " )
204+ mirrorCall(nme.Select , reify(qual), reify(name))
205+ case SelectFromTypeTree (qual, name) =>
206+ if (reifyDebug) println(s " reifying SelectFromTypeTree( $qual, $name) " )
207+ mirrorCall(nme.SelectFromTypeTree , reify(qual), reify(name))
208+ case _ if sym.isLocatable =>
209+ if (reifyDebug) println(s " tpe is locatable: reify as Ident( $sym) " )
210+ mirrorBuildCall(nme.Ident , reify(sym))
211+ case _ =>
212+ if (reifyDebug) println(s " tpe is not locatable: reify as TypeTree( $tpe) " )
213+ mirrorBuildCall(nme.TypeTree , reify(tpe))
206214 }
207215 }
208216 }
0 commit comments