Skip to content

Commit 4947141

Browse files
committed
Convert test classes (1)
1 parent 5d350e5 commit 4947141

20 files changed

+47
-41
lines changed

compiler/src/dotty/tools/dotc/classpath/ZipAndJarFileLookupFactory.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import scala.annotation.tailrec
1212
import dotty.tools.io.{AbstractFile, ClassPath, ClassRepresentation, FileZipArchive, ManifestResources}
1313
import dotty.tools.dotc.core.Contexts.{Context, ctx}
1414
import FileUtils._
15+
import dotty.tools.dotc.core.Contexts.{Context, ctx}
1516

1617
/**
1718
* A trait providing an optional cache for classpath entries obtained from zip and jar files.

compiler/test/dotty/tools/CheckTypesTests.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import org.junit.Assert.{ assertFalse, assertTrue, fail }
55

66
import dotc.ast.Trees._
77
import dotc.core.Decorators._
8+
import dotc.core.Contexts.{Context, ctx}
89

910
class CheckTypeTest extends DottyTest {
1011
@Test
@@ -27,7 +28,7 @@ class CheckTypeTest extends DottyTest {
2728

2829
checkTypes(source, types: _*) {
2930
case (List(a, b, lu, li, lr, ls, la, lb), context) =>
30-
implicit val ctx = context
31+
given Context = context
3132

3233
assertTrue ( b <:< a)
3334
assertTrue (li <:< lu)
@@ -59,7 +60,7 @@ class CheckTypeTest extends DottyTest {
5960

6061
checkTypes(source, List(typesA, typesB)) {
6162
case (List(sups, subs), context) =>
62-
implicit val ctx = context
63+
given Context = context
6364

6465
sups.lazyZip(subs).foreach { (sup, sub) => assertTrue(sub <:< sup) }
6566

compiler/test/dotty/tools/DottyTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ trait DottyTest extends ContextEscapeDetection {
8080
val gatheredSource = s"${source}\nobject A$dummyName {$vals}"
8181
checkCompile("typer", gatheredSource) {
8282
(tree, context) =>
83-
implicit val ctx = context
83+
given Context = context
8484
val findValDef: (List[tpd.ValDef], tpd.Tree) => List[tpd.ValDef] =
8585
(acc , tree) => {
8686
tree match {

compiler/test/dotty/tools/DottyTypeStealer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ object DottyTypeStealer extends DottyTest {
1616
var tp: List[Type] = null
1717
checkCompile("typer", gatheredSource) {
1818
(tree, context) =>
19-
implicit val ctx = context
19+
given Context = context
2020
val findValDef: (List[ValDef], tpd.Tree) => List[ValDef] =
2121
(acc , tree) => tree match {
2222
case t: ValDef if t.name.startsWith(dummyName) => t :: acc

compiler/test/dotty/tools/backend/jvm/DottyBytecodeTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package backend.jvm
44

55
import vulpix.TestConfiguration
66

7-
import dotc.core.Contexts.{Context, ContextBase}
7+
import dotc.core.Contexts.{Context, ContextBase, ctx}
88
import dotc.core.Comments.{ContextDoc, ContextDocstrings}
99
import dotc.core.Phases.Phase
1010
import dotc.Compiler
@@ -58,7 +58,7 @@ trait DottyBytecodeTest {
5858

5959
/** Checks source code from raw strings */
6060
def checkBCode(scalaSources: List[String], javaSources: List[String] = Nil)(checkOutput: AbstractFile => Unit): Unit = {
61-
implicit val ctx: Context = initCtx
61+
given Context = initCtx
6262

6363
val compiler = new Compiler
6464
val run = compiler.newRun

compiler/test/dotty/tools/compilerSupport.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import dotc.core.Comments.{ContextDoc, ContextDocstrings}
2020
def inCompilerContext[T](classpath: String, separateRun: Boolean = true, scalaSources: String*)(op: Context ?=> T): T =
2121
val compiler = Compiler()
2222
val rootCtx = initCtx(classpath)
23-
val firstRun = compiler.newRun(rootCtx)
23+
val firstRun = compiler.newRun(using rootCtx)
2424
firstRun.compileFromStrings(scalaSources.toList)
2525
val opRun = if separateRun
26-
then compiler.newRun(rootCtx)
26+
then compiler.newRun(using rootCtx)
2727
else firstRun
2828
op(using opRun.runContext)
2929

compiler/test/dotty/tools/dotc/ast/DesugarTests.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class DesugarTests extends DottyTest {
2323

2424
@Test def caseClassHasCorrectMembers: Unit =
2525
checkCompile("typer", "case class Foo(x: Int, y: String)") { (tree, context) =>
26-
implicit val ctx = context
26+
given Context = context
2727
val ccTree = tree.find(tree => tree.symbol.name == typeName("Foo")).get
2828
val List(_, foo) = defPath(ccTree.symbol, tree).map(_.symbol.info)
2929

@@ -38,7 +38,7 @@ class DesugarTests extends DottyTest {
3838

3939
@Test def caseClassCompanionHasCorrectMembers: Unit =
4040
checkCompile("typer", "case class Foo(x: Int, y: String)") { (tree, context) =>
41-
implicit val ctx = context
41+
given Context = context
4242
val ccTree = tree.find(tree => tree.symbol.name == termName("Foo")).get
4343
val List(_, foo) = defPath(ccTree.symbol, tree).map(_.symbol.info)
4444

compiler/test/dotty/tools/dotc/ast/TreeInfoTest.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import core.StdNames.nme
88
import core.Types._
99
import core.Symbols._
1010
import org.junit.Assert._
11+
import core.Contexts.{Context, ctx}
1112

1213
class TreeInfoTest extends DottyTest {
1314

@@ -16,7 +17,7 @@ class TreeInfoTest extends DottyTest {
1617
@Test
1718
def testDefPath: Unit = checkCompile("typer", "class A { def bar = { val x = { val z = 0; 0} }} ") {
1819
(tree, context) =>
19-
implicit val ctx = context
20+
given Context = context
2021
val xTree = tree.find(tree => tree.symbol.name == termName("x")).get
2122
val path = defPath(xTree.symbol, tree)
2223
assertEquals(List(

compiler/test/dotty/tools/dotc/classpath/ZipAndJarFileLookupFactoryTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import org.junit.Test
44
import java.nio.file._
55
import java.nio.file.attribute.FileTime
66

7-
import dotty.tools.dotc.core.Contexts.{Context, ContextBase}
7+
import dotty.tools.dotc.core.Contexts.{Context, ContextBase, ctx}
88
import dotty.tools.io.AbstractFile
99

1010

@@ -16,7 +16,7 @@ class ZipAndJarFileLookupFactoryTest {
1616
val f = Files.createTempFile("test-", ".jar")
1717
Files.delete(f)
1818

19-
implicit val ctx: Context = new ContextBase().initialCtx
19+
given Context = new ContextBase().initialCtx
2020
assert(!ctx.settings.YdisableFlatCpCaching.value) // we're testing with our JAR metadata caching enabled.
2121

2222
def createCp = ZipAndJarClassPathFactory.create(AbstractFile.getFile(f))

compiler/test/dotty/tools/dotc/parsing/ModifiersParsingTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import core.Contexts._
1414
import core.Flags
1515

1616
object ModifiersParsingTest {
17-
implicit val ctx: Context = (new ContextBase).initialCtx
17+
given Context = (new ContextBase).initialCtx
1818

1919
def parse(code: String): Tree = {
2020
val (_, stats) = new Parser(SourceFile.virtual("<meta>", code)).templateStatSeq()
@@ -74,7 +74,7 @@ object ModifiersParsingTest {
7474

7575

7676
class ModifiersParsingTest {
77-
import ModifiersParsingTest._
77+
import ModifiersParsingTest.{_, given _}
7878

7979

8080
@Test def valDef = {

0 commit comments

Comments
 (0)