Skip to content

Commit 8440220

Browse files
Address review
1 parent b9d4893 commit 8440220

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -379,12 +379,19 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
379379
* where <prefix> is the full name of the owner followed by a "." minus
380380
* the prefix "dotty.language.".
381381
*/
382-
def featureEnabled(feature: TermName): Boolean = {
383-
def hasImport =
382+
def featureEnabled(feature: TermName, owner: Symbol = NoSymbol): Boolean = {
383+
def hasImport = {
384+
val owner1 = if (!owner.exists) defn.LanguageModuleClass else owner
384385
ctx.importInfo != null &&
385-
ctx.importInfo.featureImported(feature)(ctx.withPhase(ctx.typerPhase))
386-
val hasOption =
387-
ctx.base.settings.language.value.exists(s => s == feature.toString || s == "_")
386+
ctx.importInfo.featureImported(feature, owner1)(ctx.withPhase(ctx.typerPhase))
387+
}
388+
val hasOption = {
389+
def toPrefix(sym: Symbol): String =
390+
if (!sym.exists) ""
391+
else toPrefix(sym.owner) + sym.name + "."
392+
val featureName = toPrefix(owner) + feature
393+
ctx.base.settings.language.value exists (s => s == featureName || s == "_")
394+
}
388395
hasOption || hasImport
389396
}
390397

compiler/src/dotty/tools/dotc/typer/ImportInfo.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,15 @@ class ImportInfo(symf: Context => Symbol, val selectors: List[untpd.Tree],
146146
private[this] var myUnimported: Symbol = _
147147

148148
/** Does this import clause or a preceding import clause import `owner.feature`? */
149-
def featureImported(feature: TermName)(implicit ctx: Context): Boolean = {
150-
val owner: Symbol = defn.LanguageModuleClass
149+
def featureImported(feature: TermName, owner: Symbol)(implicit ctx: Context): Boolean = {
151150
def compute = {
152-
val isImportOwner = site.widen.typeSymbol `eq` owner
151+
val isImportOwner = site.widen.typeSymbol.eq(owner)
153152
if (isImportOwner && originals.contains(feature)) true
154153
else if (isImportOwner && excluded.contains(feature)) false
155154
else {
156155
var c = ctx.outer
157156
while (c.importInfo eq ctx.importInfo) c = c.outer
158-
(c.importInfo != null) && c.importInfo.featureImported(feature)(c)
157+
(c.importInfo != null) && c.importInfo.featureImported(feature, owner)(c)
159158
}
160159
}
161160
if (lastOwner.ne(owner) || !lastResults.contains(feature)) {

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class CompilationTests extends ParallelTesting {
3131

3232
// Positive tests ------------------------------------------------------------
3333

34-
@Test // enable to test compileStdLib separately with detailed stats
34+
// @Test // enable to test compileStdLib separately with detailed stats
3535
def compileStdLibOnly: Unit = {
3636
implicit val testGroup: TestGroup = TestGroup("compileStdLibOnly")
3737
compileList("compileStdLib", TestSources.stdLibSources, scala2Mode.and("-migration", "-Yno-inline"))

0 commit comments

Comments
 (0)