@@ -277,8 +277,11 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
277277 *
278278 * import owner.feature
279279 *
280- * (the feature may be bunched with others, or renamed, but wildcard imports
281- * don't count).
280+ * and there is no visible nested import that excludes the feature, as in
281+ *
282+ * import owner.{ feature => _ }
283+ *
284+ * The feature may be bunched with others, or renamed, but wildcard imports don't count.
282285 *
283286 * 2. The feature is enabled by a compiler option
284287 *
@@ -293,13 +296,16 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
293296 else toPrefix(sym.owner) + sym.name + " ."
294297 def featureName = toPrefix(owner) + feature
295298 def hasImport (implicit ctx : Context ): Boolean = {
296- if (ctx.importInfo == null || (ctx.importInfo.site.widen.typeSymbol ne owner)) false
297- else if (ctx.importInfo.excluded.contains(feature)) false
298- else if (ctx.importInfo.originals.contains(feature)) true
299+ if (ctx.importInfo eq null ) false
299300 else {
300- var c = ctx.outer
301- while (c.importInfo eq ctx.importInfo) c = c.outer
302- hasImport(c)
301+ val isImportOwner = ctx.importInfo.site.widen.typeSymbol eq owner
302+ if (isImportOwner && ctx.importInfo.originals.contains(feature)) true
303+ else if (isImportOwner && ctx.importInfo.excluded.contains(feature)) false
304+ else {
305+ var c = ctx.outer
306+ while (c.importInfo eq ctx.importInfo) c = c.outer
307+ hasImport(c)
308+ }
303309 }
304310 }
305311 def hasOption = ctx.base.settings.language.value exists (s => s == featureName || s == " _" )
0 commit comments