@@ -174,6 +174,16 @@ class Typer extends Namer
174
174
previous
175
175
}
176
176
177
+ /** Recurse in outer context. If final result is same as `previous`, check that it
178
+ * is new or shadowed. This order of checking is necessary since an
179
+ * outer package-level definition might trump two conflicting inner
180
+ * imports, so no error should be issued in that case. See i7876.scala.
181
+ */
182
+ def recurAndCheckNewOrShadowed (previous : Type , prevPrec : BindingPrec , prevCtx : Context )(given Context ): Type =
183
+ val found = findRefRecur(previous, prevPrec, prevCtx)
184
+ if found eq previous then checkNewOrShadowed(found, prevPrec)
185
+ else found
186
+
177
187
def selection (imp : ImportInfo , name : Name , checkBounds : Boolean ) =
178
188
if imp.sym.isCompleting then
179
189
ctx.warning(i " cyclic ${imp.sym}, ignored " , posd.sourcePos)
@@ -323,11 +333,11 @@ class Typer extends Namer
323
333
else if (isPossibleImport(NamedImport ) && (curImport ne outer.importInfo)) {
324
334
val namedImp = namedImportRef(curImport)
325
335
if (namedImp.exists)
326
- findRefRecur(checkNewOrShadowed( namedImp, NamedImport ), NamedImport , ctx)(outer)
336
+ recurAndCheckNewOrShadowed( namedImp, NamedImport , ctx)(given outer )
327
337
else if (isPossibleImport(WildImport ) && ! curImport.sym.isCompleting) {
328
338
val wildImp = wildImportRef(curImport)
329
339
if (wildImp.exists)
330
- findRefRecur(checkNewOrShadowed( wildImp, WildImport ), WildImport , ctx)(outer)
340
+ recurAndCheckNewOrShadowed( wildImp, WildImport , ctx)(given outer )
331
341
else {
332
342
updateUnimported()
333
343
loop(ctx)(outer)
0 commit comments