@@ -191,23 +191,26 @@ class Typer extends Namer
191
191
if found eq previous then checkNewOrShadowed(found, prevPrec)
192
192
else found
193
193
194
- def selection (imp : ImportInfo , name : Name , checkBounds : Boolean ) =
195
- if imp.sym.isCompleting then
196
- report.warning(i " cyclic ${imp.sym}, ignored " , pos)
197
- NoType
198
- else if unimported.nonEmpty && unimported.contains(imp.site.termSymbol) then
199
- NoType
200
- else
201
- val pre = imp.site
202
- var denot = pre.memberBasedOnFlags(name, required, EmptyFlags )
203
- .accessibleFrom(pre)(using refctx)
194
+ def selection (imp : ImportInfo , name : Name , checkBounds : Boolean ): Type =
195
+ imp.sym.info match
196
+ case ImportType (expr) =>
197
+ val pre = expr.tpe
198
+ var denot = pre.memberBasedOnFlags(name, required, EmptyFlags )
199
+ .accessibleFrom(pre)(using refctx)
204
200
// Pass refctx so that any errors are reported in the context of the
205
201
// reference instead of the context of the import scope
206
- if checkBounds && denot.exists then
207
- denot = denot.filterWithPredicate { mbr =>
208
- mbr.matchesImportBound(if mbr.symbol.is(Given ) then imp.givenBound else imp.wildcardBound)
209
- }
210
- if reallyExists(denot) then pre.select(name, denot) else NoType
202
+ if denot.exists then
203
+ if checkBounds then
204
+ denot = denot.filterWithPredicate { mbr =>
205
+ mbr.matchesImportBound(if mbr.symbol.is(Given ) then imp.givenBound else imp.wildcardBound)
206
+ }
207
+ if reallyExists(denot) then
208
+ if unimported.isEmpty || ! unimported.contains(pre.termSymbol) then
209
+ return pre.select(name, denot)
210
+ case _ =>
211
+ if imp.sym.isCompleting then
212
+ report.warning(i " cyclic ${imp.sym}, ignored " , pos)
213
+ NoType
211
214
212
215
/** The type representing a named import with enclosing name when imported
213
216
* from given `site` and `selectors`.
@@ -356,7 +359,7 @@ class Typer extends Namer
356
359
if ! curOwner.is(Package ) || isDefinedInCurrentUnit(defDenot) then
357
360
result = checkNewOrShadowed(found, Definition ) // no need to go further out, we found highest prec entry
358
361
found match
359
- case found : NamedType if ctx.owner .isClass && isInherited(found.denot) =>
362
+ case found : NamedType if curOwner .isClass && isInherited(found.denot) =>
360
363
checkNoOuterDefs(found.denot, ctx, ctx)
361
364
case _ =>
362
365
else
@@ -373,8 +376,8 @@ class Typer extends Namer
373
376
val outer = ctx.outer
374
377
val curImport = ctx.importInfo
375
378
def updateUnimported () =
376
- if (curImport.unimported.exists ) unimported += curImport.unimported
377
- if (ctx.owner .is(Package ) && curImport != null && curImport.isRootImport && previous.exists)
379
+ if (curImport.unimported ne NoSymbol ) unimported += curImport.unimported
380
+ if (curOwner .is(Package ) && curImport != null && curImport.isRootImport && previous.exists)
378
381
previous // no more conflicts possible in this case
379
382
else if (isPossibleImport(NamedImport ) && (curImport ne outer.importInfo)) {
380
383
val namedImp = namedImportRef(curImport)
0 commit comments