@@ -15,17 +15,20 @@ object ImportInfo {
1515 val selectors = untpd.Ident (nme.WILDCARD ) :: Nil
1616 def expr = tpd.Ident (refFn())
1717 def imp = tpd.Import (expr, selectors)
18- new ImportInfo (imp.symbol, selectors, isRootImport = true )
18+ new ImportInfo (imp.symbol, selectors, None , isRootImport = true )
1919 }
2020}
2121
2222/** Info relating to an import clause
23- * @param sym The import symbol defined by the clause
24- * @param selectors The selector clauses
25- * @param rootImport true if this is one of the implicit imports of scala, java.lang
26- * or Predef in the start context, false otherwise.
23+ * @param sym The import symbol defined by the clause
24+ * @param selectors The selector clauses
25+ * @param symNameOpt Optionally, the name of the import symbol. None for root imports.
26+ * Defined for all explicit imports from ident or select nodes.
27+ * @param isRootImport true if this is one of the implicit imports of scala, java.lang,
28+ * scala.Predef or dotty.DottyPredef in the start context, false otherwise.
2729 */
28- class ImportInfo (symf : => Symbol , val selectors : List [untpd.Tree ], val isRootImport : Boolean = false )(implicit ctx : Context ) {
30+ class ImportInfo (symf : => Symbol , val selectors : List [untpd.Tree ],
31+ symNameOpt : Option [TermName ], val isRootImport : Boolean = false )(implicit ctx : Context ) {
2932
3033 lazy val sym = symf
3134
@@ -105,11 +108,11 @@ class ImportInfo(symf: => Symbol, val selectors: List[untpd.Tree], val isRootImp
105108 */
106109 lazy val unimported : Symbol = {
107110 lazy val sym = site.termSymbol
108- val hasMaskingSelector = selectors exists {
109- case Thicket (_ :: Ident (nme. WILDCARD ) :: Nil ) => true
110- case _ => false
111+ def maybeShadowsRoot = symNameOpt match {
112+ case Some (symName) => defn. ShadowableImportNames .contains(symName)
113+ case None => false
111114 }
112- if (hasMaskingSelector && defn.RootImportTypes .exists(_.symbol == sym)) sym
115+ if (maybeShadowsRoot && defn.RootImportTypes .exists(_.symbol == sym)) sym
113116 else NoSymbol
114117 }
115118
0 commit comments