diff options
author | Nicolas Stucki <nicolas.stucki@gmail.com> | 2016-06-06 14:16:10 +0200 |
---|---|---|
committer | Nicolas Stucki <nicolas.stucki@gmail.com> | 2016-07-07 11:10:45 +0200 |
commit | 7e00c724273d432c8900c0e8ec852bb77357958e (patch) | |
tree | e38ca49a5b443df99088a91b14d88340e121dab1 | |
parent | 5a7cacbb37f8f1edfded03a095eb45c04a883185 (diff) | |
download | dotty-7e00c724273d432c8900c0e8ec852bb77357958e.tar.gz dotty-7e00c724273d432c8900c0e8ec852bb77357958e.tar.bz2 dotty-7e00c724273d432c8900c0e8ec852bb77357958e.zip |
Fix TypeOps.featureEnabled ignoring import disabling.
-rw-r--r-- | src/dotty/tools/dotc/core/TypeOps.scala | 19 | ||||
-rw-r--r-- | tests/neg/dynamicNoImport.scala | 10 |
2 files changed, 20 insertions, 9 deletions
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala index 3da119a9c..63d8dff3b 100644 --- a/src/dotty/tools/dotc/core/TypeOps.scala +++ b/src/dotty/tools/dotc/core/TypeOps.scala @@ -458,15 +458,16 @@ trait TypeOps { this: Context => // TODO: Make standalone object. if (!sym.exists || (sym eq defn.LanguageModuleClass) || (sym eq defn.Scala2LanguageModuleRef)) "" else toPrefix(sym.owner) + sym.name + "." def featureName = toPrefix(owner) + feature - def hasImport(implicit ctx: Context): Boolean = ( - ctx.importInfo != null - && ( (ctx.importInfo.site.widen.typeSymbol eq owner) - && ctx.importInfo.originals.contains(feature) - || - { var c = ctx.outer - while (c.importInfo eq ctx.importInfo) c = c.outer - hasImport(c) - })) + def hasImport(implicit ctx: Context): Boolean = { + if (ctx.importInfo == null || (ctx.importInfo.site.widen.typeSymbol ne owner)) false + else if (ctx.importInfo.excluded.contains(feature)) false + else if (ctx.importInfo.originals.contains(feature)) true + else { + var c = ctx.outer + while (c.importInfo eq ctx.importInfo) c = c.outer + hasImport(c) + } + } def hasOption = ctx.base.settings.language.value exists (s => s == featureName || s == "_") hasImport(ctx.withPhase(ctx.typerPhase)) || hasOption } diff --git a/tests/neg/dynamicNoImport.scala b/tests/neg/dynamicNoImport.scala index cfaac66a4..c009d91a4 100644 --- a/tests/neg/dynamicNoImport.scala +++ b/tests/neg/dynamicNoImport.scala @@ -1,3 +1,13 @@ class Foo extends scala.Dynamic // error trait Bar extends scala.Dynamic // error object Baz extends scala.Dynamic // error + +package A { + import scala.language.dynamics + package B { + import scala.language.{ dynamics => _ } + class Foo extends scala.Dynamic // error + trait Bar extends scala.Dynamic // error + object Baz extends scala.Dynamic // error + } +} |