@@ -74,7 +74,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
74
74
* Note: It would be more proper to move importedFromRoot into typedIdent.
75
75
* We should check that this has no performance degradation, however.
76
76
*/
77
- private var importedFromRoot : Set [Symbol ] = Set ()
77
+ private var unimported : Set [Symbol ] = Set ()
78
78
79
79
/** Temporary data item for single call to typed ident:
80
80
* This symbol would be found under Scala2 mode, but is not
@@ -102,15 +102,6 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
102
102
*/
103
103
def error (msg : => Message , pos : Position ) = ctx.error(msg, pos)
104
104
105
- /** Is this import a root import that has been shadowed by an explicit
106
- * import in the same program?
107
- */
108
- def isDisabled (imp : ImportInfo , site : Type ): Boolean = {
109
- if (imp.isRootImport && (importedFromRoot contains site.termSymbol)) return true
110
- if (imp.hiddenRoot.exists) importedFromRoot += imp.hiddenRoot
111
- false
112
- }
113
-
114
105
/** Does this identifier appear as a constructor of a pattern? */
115
106
def isPatternConstr =
116
107
if (ctx.mode.isExpr && (ctx.outer.mode is Mode .Pattern ))
@@ -196,7 +187,9 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
196
187
}
197
188
198
189
def selection (name : Name ) =
199
- if (imp.sym.isCompleting) {
190
+ if (unimported.contains(imp.site.termSymbol))
191
+ NoType
192
+ else if (imp.sym.isCompleting) {
200
193
ctx.warning(i " cyclic ${imp.sym}, ignored " , tree.pos)
201
194
NoType
202
195
}
@@ -227,7 +220,9 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
227
220
def wildImportRef (imp : ImportInfo )(implicit ctx : Context ): Type = {
228
221
if (imp.isWildcardImport) {
229
222
val pre = imp.site
230
- if (! isDisabled(imp, pre) && ! (imp.excluded contains name.toTermName) && name != nme.CONSTRUCTOR ) {
223
+ if (! unimported.contains(pre.termSymbol) &&
224
+ ! imp.excluded.contains(name.toTermName) &&
225
+ name != nme.CONSTRUCTOR ) {
231
226
val denot = pre.member(name).accessibleFrom(pre)(refctx)
232
227
if (reallyExists(denot)) return pre.select(name, denot)
233
228
}
@@ -284,6 +279,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
284
279
if (result.exists) result
285
280
else { // find import
286
281
val curImport = ctx.importInfo
282
+ def updateUnimported () =
283
+ if (curImport.unimported.exists) unimported += curImport.unimported
287
284
if (ctx.owner.is(Package ) && curImport != null && curImport.isRootImport && previous.exists)
288
285
previous // no more conflicts possible in this case
289
286
else if (isPossibleImport(namedImport) && (curImport ne outer.importInfo)) {
@@ -294,8 +291,15 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
294
291
val wildImp = wildImportRef(curImport)
295
292
if (wildImp.exists)
296
293
findRef(checkNewOrShadowed(wildImp, wildImport), wildImport, ctx)(outer)
297
- else loop(outer)
298
- } else loop(outer)
294
+ else {
295
+ updateUnimported()
296
+ loop(outer)
297
+ }
298
+ }
299
+ else {
300
+ updateUnimported()
301
+ loop(outer)
302
+ }
299
303
}
300
304
else loop(outer)
301
305
}
@@ -316,9 +320,9 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
316
320
}
317
321
318
322
val rawType = {
319
- val saved1 = importedFromRoot
323
+ val saved1 = unimported
320
324
val saved2 = foundUnderScala2
321
- importedFromRoot = Set .empty
325
+ unimported = Set .empty
322
326
foundUnderScala2 = NoType
323
327
try {
324
328
var found = findRef(NoType , BindingPrec .nothingBound, NoContext )
@@ -332,7 +336,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
332
336
found
333
337
}
334
338
finally {
335
- importedFromRoot = saved1
339
+ unimported = saved1
336
340
foundUnderScala2 = saved2
337
341
}
338
342
}
0 commit comments