Skip to content

Commit ad96b03

Browse files
committed
Fix #3736: Search all imports for language features
1 parent be50d2c commit ad96b03

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

compiler/src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -292,16 +292,16 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
292292
if (!sym.exists || (sym eq defn.LanguageModuleClass)) ""
293293
else toPrefix(sym.owner) + sym.name + "."
294294
def featureName = toPrefix(owner) + feature
295-
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-
else {
300-
var c = ctx.outer
301-
while (c.importInfo eq ctx.importInfo) c = c.outer
302-
hasImport(c)
295+
def hasImport(implicit ctx: Context): Boolean =
296+
ctx.importInfo != null && {
297+
ctx.importInfo.site.widen.typeSymbol == owner &&
298+
!ctx.importInfo.excluded.contains(feature) &&
299+
ctx.importInfo.originals.contains(feature) || {
300+
var c = ctx.outer
301+
while (c.importInfo eq ctx.importInfo) c = c.outer
302+
hasImport(c)
303+
}
303304
}
304-
}
305305
def hasOption = ctx.base.settings.language.value exists (s => s == featureName || s == "_")
306306
hasImport(ctx.withPhase(ctx.typerPhase)) || hasOption
307307
}

tests/pos/i3736.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import scala.language.dynamics
2+
import scala.Nil
3+
class Foo() extends Dynamic

0 commit comments

Comments
 (0)