Skip to content

Commit ec7eeca

Browse files
committed
Fix TypeOps.featureEnabled ignoring import disabling.
1 parent 9a5f9c8 commit ec7eeca

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -458,15 +458,16 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
458458
if (!sym.exists || (sym eq defn.LanguageModuleClass) || (sym eq defn.Scala2LanguageModuleRef)) ""
459459
else toPrefix(sym.owner) + sym.name + "."
460460
def featureName = toPrefix(owner) + feature
461-
def hasImport(implicit ctx: Context): Boolean = (
462-
ctx.importInfo != null
463-
&& ( (ctx.importInfo.site.widen.typeSymbol eq owner)
464-
&& ctx.importInfo.originals.contains(feature)
465-
||
466-
{ var c = ctx.outer
467-
while (c.importInfo eq ctx.importInfo) c = c.outer
468-
hasImport(c)
469-
}))
461+
def hasImport(implicit ctx: Context): Boolean = {
462+
if (ctx.importInfo == null || (ctx.importInfo.site.widen.typeSymbol ne owner)) false
463+
else if (ctx.importInfo.excluded.contains(feature)) false
464+
else if (ctx.importInfo.originals.contains(feature)) true
465+
else {
466+
var c = ctx.outer
467+
while (c.importInfo eq ctx.importInfo) c = c.outer
468+
hasImport(c)
469+
}
470+
}
470471
def hasOption = ctx.base.settings.language.value exists (s => s == featureName || s == "_")
471472
hasImport(ctx.withPhase(ctx.typerPhase)) || hasOption
472473
}

tests/neg/dynamicNoImport.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
class Foo extends scala.Dynamic // error
22
trait Bar extends scala.Dynamic // error
33
object Baz extends scala.Dynamic // error
4+
5+
package A {
6+
import scala.language.dynamics
7+
package B {
8+
import scala.language.{ dynamics => _ }
9+
class Foo extends scala.Dynamic // error
10+
trait Bar extends scala.Dynamic // error
11+
object Baz extends scala.Dynamic // error
12+
}
13+
}

0 commit comments

Comments
 (0)