@@ -33,7 +33,7 @@ object ImportInfo {
3333 val expr = tpd.Ident (ref.refFn()) // refFn must be called in the context of ImportInfo.sym
3434 tpd.Import (expr, selectors).symbol
3535
36- ImportInfo (sym, selectors, None , isRootImport = true )
36+ ImportInfo (sym, selectors, untpd. EmptyTree , isRootImport = true )
3737
3838 extension (c : Context )
3939 def withRootImports (rootRefs : List [RootRef ])(using Context ): Context =
@@ -42,22 +42,26 @@ object ImportInfo {
4242 def withRootImports : Context =
4343 given Context = c
4444 c.withRootImports(defn.rootImportFns)
45-
4645}
4746
4847/** Info relating to an import clause
4948 * @param sym The import symbol defined by the clause
5049 * @param selectors The selector clauses
51- * @param symNameOpt Optionally, the name of the import symbol. None for root imports.
50+ * @param qualifier The import qualifier, or EmptyTree for root imports.
5251 * Defined for all explicit imports from ident or select nodes.
5352 * @param isRootImport true if this is one of the implicit imports of scala, java.lang,
5453 * scala.Predef in the start context, false otherwise.
5554 */
5655class ImportInfo (symf : Context ?=> Symbol ,
5756 val selectors : List [untpd.ImportSelector ],
58- symNameOpt : Option [ TermName ] ,
57+ val qualifier : untpd. Tree ,
5958 val isRootImport : Boolean = false ) extends Showable {
6059
60+ private def symNameOpt = qualifier match {
61+ case ref : untpd.RefTree => Some (ref.name.asTermName)
62+ case _ => None
63+ }
64+
6165 def sym (using Context ): Symbol = {
6266 if (mySym == null ) {
6367 mySym = symf
@@ -177,6 +181,8 @@ class ImportInfo(symf: Context ?=> Symbol,
177181 assert(myUnimported != null )
178182 myUnimported
179183
184+ private val isLanguageImport : Boolean = untpd.isLanguageImport(qualifier)
185+
180186 private var myUnimported : Symbol = _
181187
182188 private var myOwner : Symbol = null
@@ -185,14 +191,15 @@ class ImportInfo(symf: Context ?=> Symbol,
185191 /** Does this import clause or a preceding import clause import `owner.feature`? */
186192 def featureImported (feature : TermName , owner : Symbol )(using Context ): Boolean =
187193
188- def compute =
189- val isImportOwner = site.typeSymbol.eq(owner)
190- if isImportOwner && forwardMapping.contains(feature) then true
191- else if isImportOwner && excluded.contains(feature) then false
192- else
193- var c = ctx.outer
194- while c.importInfo eq ctx.importInfo do c = c.outer
195- (c.importInfo != null ) && c.importInfo.featureImported(feature, owner)(using c)
194+ def compute : Boolean =
195+ if isLanguageImport then
196+ val isImportOwner = site.typeSymbol.eq(owner)
197+ if isImportOwner then
198+ if forwardMapping.contains(feature) then return true
199+ if excluded.contains(feature) then return false
200+ var c = ctx.outer
201+ while c.importInfo eq ctx.importInfo do c = c.outer
202+ (c.importInfo != null ) && c.importInfo.featureImported(feature, owner)(using c)
196203
197204 if myOwner.ne(owner) || ! myResults.contains(feature) then
198205 myOwner = owner
0 commit comments