Skip to content

Commit

Permalink
Improve the usage of inclusive language (#22360)
Browse files Browse the repository at this point in the history
Changes:
- blacklist -> excludelist

Discussion:
- #21988

Fixes #21988
  • Loading branch information
Linyxus authored Jan 16, 2025
2 parents 64e7aa7 + 910fca9 commit 0f9e502
Show file tree
Hide file tree
Showing 28 changed files with 63 additions and 63 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ object Contexts {
* risk of capturing complete trees.
* - To make sure these rules are kept, it would be good to do a sanity
* check using bytecode inspection with javap or scalap: Keep track
* of all class fields of type context; allow them only in whitelisted
* of all class fields of type context; allow them only in allowlisted
* classes (which should be short-lived).
*/
abstract class Context(val base: ContextBase) { thiscontext =>
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1972,7 +1972,7 @@ class Definitions {
Some((args.init, args.last))
case _ => None

/** A whitelist of Scala-2 classes that are known to be pure */
/** A allowlist of Scala-2 classes that are known to be pure */
def isAssuredNoInits(sym: Symbol): Boolean =
(sym `eq` SomeClass) || isTupleClass(sym)

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Names.scala
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ object Names {
}

/** It's OK to take a toString if the stacktrace does not contain a method
* from GenBCode or it also contains one of the whitelisted methods below.
* from GenBCode or it also contains one of the allowed methods below.
*/
private def toStringOK = {
val trace: Array[StackTraceElement] = Thread.currentThread.nn.getStackTrace.asInstanceOf[Array[StackTraceElement]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ class ClassfileParser(

// Nothing$ and Null$ were incorrectly emitted with a Scala attribute
// instead of ScalaSignature before 2.13.0-M2, see https://github.com/scala/scala/pull/5952
private val scalaUnpickleWhitelist = List(tpnme.nothingClass, tpnme.nullClass)
private val scalaUnpickleAllowlist = List(tpnme.nothingClass, tpnme.nullClass)

/** Parse inner classes. Expects `in.bp` to point to the superclass entry.
* Restores the old `bp`.
Expand Down Expand Up @@ -1152,7 +1152,7 @@ class ClassfileParser(
return None
}

if scan(tpnme.ScalaATTR) && !scalaUnpickleWhitelist.contains(classRoot.name)
if scan(tpnme.ScalaATTR) && !scalaUnpickleAllowlist.contains(classRoot.name)
&& !(classRoot.name.startsWith("Tuple") && classRoot.name.endsWith("$sp"))
&& !(classRoot.name.startsWith("Product") && classRoot.name.endsWith("$sp"))
then
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/init/Objects.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Objects(using Context @constructorOnly):
val immutableLazyList: Symbol = requiredModule("scala.collection.immutable.LazyList")
val LazyList_empty: Symbol = immutableLazyList.requiredValue("_empty")

val whiteList: Set[Symbol] = Set(SetNode_EmptySetNode, HashSet_EmptySet, Vector_EmptyIterator, MapNode_EmptyMapNode, HashMap_EmptyMap, LazyList_empty)
val allowList: Set[Symbol] = Set(SetNode_EmptySetNode, HashSet_EmptySet, Vector_EmptyIterator, MapNode_EmptyMapNode, HashMap_EmptyMap, LazyList_empty)

// ----------------------------- abstract domain -----------------------------

Expand Down Expand Up @@ -1735,7 +1735,7 @@ class Objects(using Context @constructorOnly):
tpl.body.foreach {
case vdef : ValDef if !vdef.symbol.is(Flags.Lazy) && !vdef.rhs.isEmpty =>
val sym = vdef.symbol
val res = if (whiteList.contains(sym)) Bottom else eval(vdef.rhs, thisV, klass)
val res = if (allowList.contains(sym)) Bottom else eval(vdef.rhs, thisV, klass)
if sym.is(Flags.Mutable) then
val addr = Heap.fieldVarAddr(summon[Regions.Data], sym, State.currentObject)
thisV.initVar(sym, addr)
Expand Down
File renamed without changes.
File renamed without changes.
54 changes: 27 additions & 27 deletions compiler/test/dotty/tools/TestSources.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,65 +12,65 @@ object TestSources {

// pos tests lists

def posFromTastyBlacklistFile: String = "compiler/test/dotc/pos-from-tasty.blacklist"
def posTestPicklingBlacklistFile: String = "compiler/test/dotc/pos-test-pickling.blacklist"
def posFromTastyExcludelistFile: String = "compiler/test/dotc/pos-from-tasty.excludelist"
def posTestPicklingExcludelistFile: String = "compiler/test/dotc/pos-test-pickling.excludelist"
def posTestRecheckExcludesFile: String = "compiler/test/dotc/pos-test-recheck.excludes"
def posLazyValsAllowlistFile: String = "compiler/test/dotc/pos-lazy-vals-tests.allowlist"
def posLintingAllowlistFile: String = "compiler/test/dotc/pos-linting.allowlist"
def posInitGlobalScala2LibraryTastyBlacklistFile: String = "compiler/test/dotc/pos-init-global-scala2-library-tasty.blacklist"
def posInitGlobalScala2LibraryTastyExcludelistFile: String = "compiler/test/dotc/pos-init-global-scala2-library-tasty.excludelist"

def posFromTastyBlacklisted: List[String] = loadList(posFromTastyBlacklistFile)
def posTestPicklingBlacklisted: List[String] = loadList(posTestPicklingBlacklistFile)
def posFromTastyExcludelisted: List[String] = loadList(posFromTastyExcludelistFile)
def posTestPicklingExcludelisted: List[String] = loadList(posTestPicklingExcludelistFile)
def posTestRecheckExcluded: List[String] = loadList(posTestRecheckExcludesFile)
def posLazyValsAllowlist: List[String] = loadList(posLazyValsAllowlistFile)
def posLintingAllowlist: List[String] = loadList(posLintingAllowlistFile)
def posInitGlobalScala2LibraryTastyBlacklisted: List[String] =
if Properties.usingScalaLibraryTasty then loadList(posInitGlobalScala2LibraryTastyBlacklistFile)
def posInitGlobalScala2LibraryTastyExcludelisted: List[String] =
if Properties.usingScalaLibraryTasty then loadList(posInitGlobalScala2LibraryTastyExcludelistFile)
else Nil

// run tests lists

def runFromTastyBlacklistFile: String = "compiler/test/dotc/run-from-tasty.blacklist"
def runTestPicklingBlacklistFile: String = "compiler/test/dotc/run-test-pickling.blacklist"
def runFromTastyExcludelistFile: String = "compiler/test/dotc/run-from-tasty.excludelist"
def runTestPicklingExcludelistFile: String = "compiler/test/dotc/run-test-pickling.excludelist"
def runTestRecheckExcludesFile: String = "compiler/test/dotc/run-test-recheck.excludes"
def runLazyValsAllowlistFile: String = "compiler/test/dotc/run-lazy-vals-tests.allowlist"
def runMacrosScala2LibraryTastyBlacklistFile: String = "compiler/test/dotc/run-macros-scala2-library-tasty.blacklist"
def runMacrosScala2LibraryTastyExcludelistFile: String = "compiler/test/dotc/run-macros-scala2-library-tasty.excludelist"

def runFromTastyBlacklisted: List[String] = loadList(runFromTastyBlacklistFile)
def runTestPicklingBlacklisted: List[String] = loadList(runTestPicklingBlacklistFile)
def runFromTastyExcludelisted: List[String] = loadList(runFromTastyExcludelistFile)
def runTestPicklingExcludelisted: List[String] = loadList(runTestPicklingExcludelistFile)
def runTestRecheckExcluded: List[String] = loadList(runTestRecheckExcludesFile)
def runLazyValsAllowlist: List[String] = loadList(runLazyValsAllowlistFile)
def runMacrosScala2LibraryTastyBlacklisted: List[String] =
if Properties.usingScalaLibraryTasty then loadList(runMacrosScala2LibraryTastyBlacklistFile)
def runMacrosScala2LibraryTastyExcludelisted: List[String] =
if Properties.usingScalaLibraryTasty then loadList(runMacrosScala2LibraryTastyExcludelistFile)
else Nil

// neg tests lists

def negScala2LibraryTastyBlacklistFile: String = "compiler/test/dotc/neg-scala2-library-tasty.blacklist"
def negInitGlobalScala2LibraryTastyBlacklistFile: String = "compiler/test/dotc/neg-init-global-scala2-library-tasty.blacklist"
def negScala2LibraryTastyExcludelistFile: String = "compiler/test/dotc/neg-scala2-library-tasty.excludelist"
def negInitGlobalScala2LibraryTastyExcludelistFile: String = "compiler/test/dotc/neg-init-global-scala2-library-tasty.excludelist"

def negScala2LibraryTastyBlacklisted: List[String] =
if Properties.usingScalaLibraryTasty then loadList(negScala2LibraryTastyBlacklistFile)
def negScala2LibraryTastyExcludelisted: List[String] =
if Properties.usingScalaLibraryTasty then loadList(negScala2LibraryTastyExcludelistFile)
else Nil
def negInitGlobalScala2LibraryTastyBlacklisted: List[String] =
if Properties.usingScalaLibraryTasty then loadList(negInitGlobalScala2LibraryTastyBlacklistFile)
def negInitGlobalScala2LibraryTastyExcludelisted: List[String] =
if Properties.usingScalaLibraryTasty then loadList(negInitGlobalScala2LibraryTastyExcludelistFile)
else Nil

// patmat tests lists

def patmatExhaustivityScala2LibraryTastyBlacklistFile: String = "compiler/test/dotc/patmat-exhaustivity-scala2-library-tasty.blacklist"
def patmatExhaustivityScala2LibraryTastyExcludelistFile: String = "compiler/test/dotc/patmat-exhaustivity-scala2-library-tasty.excludelist"

def patmatExhaustivityScala2LibraryTastyBlacklisted: List[String] =
if Properties.usingScalaLibraryTasty then loadList(patmatExhaustivityScala2LibraryTastyBlacklistFile)
def patmatExhaustivityScala2LibraryTastyExcludelisted: List[String] =
if Properties.usingScalaLibraryTasty then loadList(patmatExhaustivityScala2LibraryTastyExcludelistFile)
else Nil

// neg best effort tests lists

def negBestEffortPicklingBlacklistFile: String = "compiler/test/dotc/neg-best-effort-pickling.blacklist"
def negBestEffortUnpicklingBlacklistFile: String = "compiler/test/dotc/neg-best-effort-unpickling.blacklist"
def negBestEffortPicklingExcludelistFile: String = "compiler/test/dotc/neg-best-effort-pickling.excludelist"
def negBestEffortUnpicklingExcludelistFile: String = "compiler/test/dotc/neg-best-effort-unpickling.excludelist"

def negBestEffortPicklingBlacklisted: List[String] = loadList(negBestEffortPicklingBlacklistFile)
def negBestEffortUnpicklingBlacklisted: List[String] = loadList(negBestEffortUnpicklingBlacklistFile)
def negBestEffortPicklingExcludelisted: List[String] = loadList(negBestEffortPicklingExcludelistFile)
def negBestEffortUnpicklingExcludelisted: List[String] = loadList(negBestEffortUnpicklingExcludelistFile)

// load lists

Expand Down
4 changes: 2 additions & 2 deletions compiler/test/dotty/tools/dotc/BestEffortOptionsTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class BestEffortOptionsTests {

implicit val testGroup: TestGroup = TestGroup("negTestFromBestEffortTasty")
compileBestEffortTastyInDir(s"tests${JFile.separator}neg", bestEffortBaselineOptions,
picklingFilter = FileFilter.exclude(TestSources.negBestEffortPicklingBlacklisted),
unpicklingFilter = FileFilter.exclude(TestSources.negBestEffortUnpicklingBlacklisted)
picklingFilter = FileFilter.exclude(TestSources.negBestEffortPicklingExcludelisted),
unpicklingFilter = FileFilter.exclude(TestSources.negBestEffortUnpicklingExcludelisted)
).checkNoCrash()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class BootstrappedOnlyCompilationTests {

@Test def runMacros: Unit = {
implicit val testGroup: TestGroup = TestGroup("runMacros")
compileFilesInDir("tests/run-macros", defaultOptions.and("-Xcheck-macros"), FileFilter.exclude(TestSources.runMacrosScala2LibraryTastyBlacklisted))
compileFilesInDir("tests/run-macros", defaultOptions.and("-Xcheck-macros"), FileFilter.exclude(TestSources.runMacrosScala2LibraryTastyExcludelisted))
.checkRuns()
}

Expand Down
10 changes: 5 additions & 5 deletions compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class CompilationTests {
@Test def negAll: Unit = {
implicit val testGroup: TestGroup = TestGroup("compileNeg")
aggregateTests(
compileFilesInDir("tests/neg", defaultOptions, FileFilter.exclude(TestSources.negScala2LibraryTastyBlacklisted)),
compileFilesInDir("tests/neg", defaultOptions, FileFilter.exclude(TestSources.negScala2LibraryTastyExcludelisted)),
compileFilesInDir("tests/neg-deep-subtype", allowDeepSubtypes),
compileFilesInDir("tests/neg-custom-args/captures", defaultOptions.and("-language:experimental.captureChecking")),
compileFile("tests/neg-custom-args/sourcepath/outer/nested/Test1.scala", defaultOptions.and("-sourcepath", "tests/neg-custom-args/sourcepath")),
Expand Down Expand Up @@ -183,8 +183,8 @@ class CompilationTests {
@Test def pickling: Unit = {
implicit val testGroup: TestGroup = TestGroup("testPickling")
aggregateTests(
compileFilesInDir("tests/pos", picklingOptions, FileFilter.exclude(TestSources.posTestPicklingBlacklisted)),
compileFilesInDir("tests/run", picklingOptions, FileFilter.exclude(TestSources.runTestPicklingBlacklisted))
compileFilesInDir("tests/pos", picklingOptions, FileFilter.exclude(TestSources.posTestPicklingExcludelisted)),
compileFilesInDir("tests/run", picklingOptions, FileFilter.exclude(TestSources.runTestPicklingExcludelisted))
).checkCompile()
}

Expand Down Expand Up @@ -229,8 +229,8 @@ class CompilationTests {
// initialization tests
@Test def checkInitGlobal: Unit = {
implicit val testGroup: TestGroup = TestGroup("checkInitGlobal")
compileFilesInDir("tests/init-global/warn", defaultOptions.and("-Ysafe-init-global"), FileFilter.exclude(TestSources.negInitGlobalScala2LibraryTastyBlacklisted)).checkWarnings()
compileFilesInDir("tests/init-global/pos", defaultOptions.and("-Ysafe-init-global", "-Xfatal-warnings"), FileFilter.exclude(TestSources.posInitGlobalScala2LibraryTastyBlacklisted)).checkCompile()
compileFilesInDir("tests/init-global/warn", defaultOptions.and("-Ysafe-init-global"), FileFilter.exclude(TestSources.negInitGlobalScala2LibraryTastyExcludelisted)).checkWarnings()
compileFilesInDir("tests/init-global/pos", defaultOptions.and("-Ysafe-init-global", "-Xfatal-warnings"), FileFilter.exclude(TestSources.posInitGlobalScala2LibraryTastyExcludelisted)).checkCompile()
}

// initialization tests
Expand Down
4 changes: 2 additions & 2 deletions compiler/test/dotty/tools/dotc/FromTastyTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class FromTastyTests {

implicit val testGroup: TestGroup = TestGroup("posTestFromTasty")
compileTastyInDir(s"tests${JFile.separator}pos", defaultOptions,
fromTastyFilter = FileFilter.exclude(TestSources.posFromTastyBlacklisted)
fromTastyFilter = FileFilter.exclude(TestSources.posFromTastyExcludelisted)
).checkCompile()
}

Expand All @@ -35,7 +35,7 @@ class FromTastyTests {

implicit val testGroup: TestGroup = TestGroup("runTestFromTasty")
compileTastyInDir(s"tests${JFile.separator}run", defaultOptions,
fromTastyFilter = FileFilter.exclude(TestSources.runFromTastyBlacklisted)
fromTastyFilter = FileFilter.exclude(TestSources.runFromTastyExcludelisted)
).checkRuns()
}
}
Expand Down
10 changes: 5 additions & 5 deletions compiler/test/dotty/tools/dotc/parsing/ScannerTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.junit.Test

class ScannerTest extends DottyTest {

val blackList = List(
val excluded = List(
"/scaladoc/scala/tools/nsc/doc/html/page/Index.scala",
"/scaladoc/scala/tools/nsc/doc/html/page/Template.scala"
)
Expand All @@ -33,13 +33,13 @@ class ScannerTest extends DottyTest {
def scanDir(path: String): Unit = scanDir(Directory(path))

def scanDir(dir: Directory): Unit = {
if (blackList exists (dir.jpath.toString endsWith _))
println(s"blacklisted package: ${dir.toAbsolute.jpath}")
if (excluded exists (dir.jpath.toString endsWith _))
println(s"excluded package: ${dir.toAbsolute.jpath}")
else
for (f <- dir.files)
if (f.name.endsWith(".scala"))
if (blackList exists (f.jpath.toString endsWith _))
println(s"blacklisted file: ${f.toAbsolute.jpath}")
if (excluded exists (f.jpath.toString endsWith _))
println(s"excluded file: ${f.toAbsolute.jpath}")
else
scan(new PlainFile(f))
for (d <- dir.dirs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ class PatmatExhaustivityTest {

@Test
def patmatExhaustivity: Unit = {
val blacklisted = TestSources.patmatExhaustivityScala2LibraryTastyBlacklisted.toSet
val excluded = TestSources.patmatExhaustivityScala2LibraryTastyExcludelisted.toSet
val res = Directory(testsDir).list.toList
.filter(f => f.ext.isScala || f.isDirectory)
.filter { f =>
val path = if f.isDirectory then f.path + "/" else f.path
Properties.testsFilter.isEmpty || Properties.testsFilter.exists(path.contains)
}
.filterNot(f => blacklisted.contains(f.name))
.filterNot(f => excluded.contains(f.name))
.map(f => if f.isDirectory then compileDir(f.jpath) else compileFile(f.jpath))

val failed = res.filter(!_)
Expand Down
8 changes: 4 additions & 4 deletions compiler/test/dotty/tools/vulpix/FileFilter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ object FileFilter {
exclude(file :: files.toList)

def exclude(files: List[String]): FileFilter = new FileFilter {
private val blackList = files.toSet
def accept(file: String): Boolean = !blackList.contains(file)
private val excluded = files.toSet
def accept(file: String): Boolean = !excluded.contains(file)
}

def include(files: List[String]): FileFilter = new FileFilter {
private val whiteList = files.toSet
def accept(file: String): Boolean = whiteList.contains(file)
private val included = files.toSet
def accept(file: String): Boolean = included.contains(file)
}

object NoFilter extends FileFilter {
Expand Down
6 changes: 3 additions & 3 deletions compiler/test/dotty/tools/vulpix/ParallelTesting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1585,7 +1585,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
|
| sbt "testCompilation --from-tasty $file"
|
|This tests can be disabled by adding `${file.getName}` to `compiler${JFile.separator}test${JFile.separator}dotc${JFile.separator}$runOrPos-$listName.blacklist`
|This tests can be disabled by adding `${file.getName}` to `compiler${JFile.separator}test${JFile.separator}dotc${JFile.separator}$runOrPos-$listName.excludelist`
|
|""".stripMargin
}
Expand Down Expand Up @@ -1640,7 +1640,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
|
| sbt "scalac $bestEffortFlag $semanticDbFlag $file"
|
|These tests can be disabled by adding `${file.getName}` to `compiler${JFile.separator}test${JFile.separator}dotc${JFile.separator}neg-best-effort-pickling.blacklist`
|These tests can be disabled by adding `${file.getName}` to `compiler${JFile.separator}test${JFile.separator}dotc${JFile.separator}neg-best-effort-pickling.excludelist`
|""".stripMargin
}
}
Expand All @@ -1667,7 +1667,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
| sbt "scalac -Ybest-effort $file"
| sbt "scalac --from-tasty -Ywith-best-effort-tasty $beTastyFilesString"
|
|These tests can be disabled by adding `${file.getName}` to `compiler${JFile.separator}test${JFile.separator}dotc${JFile.separator}neg-best-effort-unpickling.blacklist`
|These tests can be disabled by adding `${file.getName}` to `compiler${JFile.separator}test${JFile.separator}dotc${JFile.separator}neg-best-effort-unpickling.excludelist`
|
|""".stripMargin
}
Expand Down
4 changes: 2 additions & 2 deletions docs/_docs/internals/best-effort-compilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@ the previously created Best Effort TASTy, with `-Yread-tasty` and `-Ywith-best-e
TreeUnpickler for those Best Effort TASTy files.

One of the goals of this feature is to keep the maintainance cost low, and to not let this feature hinder the pace of the
overall development of the compiler. Because of that, the tests can be freely disabled in `compiler/neg-best-effort.blacklist`
(testing TreePickler) and `compiler/neg-best-effort-from-tasty.blacklist` (testing TreeUnpickler).
overall development of the compiler. Because of that, the tests can be freely disabled in `compiler/neg-best-effort.excludelist`
(testing TreePickler) and `compiler/neg-best-effort-from-tasty.excludelist` (testing TreeUnpickler).
2 changes: 1 addition & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1709,7 +1709,7 @@ object Build {
)
},

// A first blacklist of tests for those that do not compile or do not link
// A first excludelist of tests for those that do not compile or do not link
(Test / managedSources) ++= {
val dir = fetchScalaJSSource.value / "test-suite"

Expand Down
4 changes: 2 additions & 2 deletions scaladoc/src/dotty/tools/scaladoc/tasty/BasicSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ trait BasicSupport:
def getAnnotations(): List[Annotation] =
// Custom annotations should be documented only if annotated by @java.lang.annotation.Documented
// We allow also some special cases
val fqNameWhitelist = Set(
val fqNameAllowlist = Set(
"scala.specialized",
"scala.throws",
"scala.transient",
Expand All @@ -56,7 +56,7 @@ trait BasicSupport:
)
val documentedSymbol = summon[Quotes].reflect.Symbol.requiredClass("java.lang.annotation.Documented")
val annotations = sym.annotations.filter { a =>
a.tpe.typeSymbol.hasAnnotation(documentedSymbol) || fqNameWhitelist.contains(a.symbol.fullName)
a.tpe.typeSymbol.hasAnnotation(documentedSymbol) || fqNameAllowlist.contains(a.symbol.fullName)
}
annotations.map(parseAnnotation).reverse

Expand Down

0 comments on commit 0f9e502

Please sign in to comment.