@@ -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 ))
@@ -201,7 +192,9 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
201
192
}
202
193
203
194
def selection (name : Name ) =
204
- if (imp.sym.isCompleting) {
195
+ if (unimported.contains(imp.site.termSymbol))
196
+ NoType
197
+ else if (imp.sym.isCompleting) {
205
198
ctx.warning(i " cyclic ${imp.sym}, ignored " , tree.pos)
206
199
NoType
207
200
}
@@ -232,7 +225,9 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
232
225
def wildImportRef (imp : ImportInfo )(implicit ctx : Context ): Type = {
233
226
if (imp.isWildcardImport) {
234
227
val pre = imp.site
235
- if (! isDisabled(imp, pre) && ! (imp.excluded contains name.toTermName) && name != nme.CONSTRUCTOR ) {
228
+ if (! unimported.contains(pre.termSymbol) &&
229
+ ! imp.excluded.contains(name.toTermName) &&
230
+ name != nme.CONSTRUCTOR ) {
236
231
val denot = pre.member(name).accessibleFrom(pre)(refctx)
237
232
if (reallyExists(denot)) return pre.select(name, denot)
238
233
}
@@ -289,6 +284,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
289
284
if (result.exists) result
290
285
else { // find import
291
286
val curImport = ctx.importInfo
287
+ def updateUnimported () =
288
+ if (curImport.unimported.exists) unimported += curImport.unimported
292
289
if (ctx.owner.is(Package ) && curImport != null && curImport.isRootImport && previous.exists)
293
290
previous // no more conflicts possible in this case
294
291
else if (isPossibleImport(namedImport) && (curImport ne outer.importInfo)) {
@@ -299,8 +296,15 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
299
296
val wildImp = wildImportRef(curImport)
300
297
if (wildImp.exists)
301
298
findRef(checkNewOrShadowed(wildImp, wildImport), wildImport, ctx)(outer)
302
- else loop(outer)
303
- } else loop(outer)
299
+ else {
300
+ updateUnimported()
301
+ loop(outer)
302
+ }
303
+ }
304
+ else {
305
+ updateUnimported()
306
+ loop(outer)
307
+ }
304
308
}
305
309
else loop(outer)
306
310
}
@@ -321,9 +325,9 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
321
325
}
322
326
323
327
val rawType = {
324
- val saved1 = importedFromRoot
328
+ val saved1 = unimported
325
329
val saved2 = foundUnderScala2
326
- importedFromRoot = Set .empty
330
+ unimported = Set .empty
327
331
foundUnderScala2 = NoType
328
332
try {
329
333
var found = findRef(NoType , BindingPrec .nothingBound, NoContext )
@@ -337,7 +341,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
337
341
found
338
342
}
339
343
finally {
340
- importedFromRoot = saved1
344
+ unimported = saved1
341
345
foundUnderScala2 = saved2
342
346
}
343
347
}
0 commit comments