Skip to content

Commit 6e54aed

Browse files
committed
Convert test classes (1)
1 parent 682ef6a commit 6e54aed

17 files changed

+43
-37
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/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 = {

compiler/test/dotty/tools/dotc/printing/PrinterTests.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import dotty.tools.dotc.ast.{Trees,tpd}
55
import dotty.tools.dotc.core.Names._
66
import dotty.tools.dotc.core.Symbols._
77
import dotty.tools.dotc.core.Decorators._
8+
import dotty.tools.dotc.core.Contexts.{Context, ctx}
9+
810
import org.junit.Assert.assertEquals
911
import org.junit.Test
1012

@@ -26,7 +28,7 @@ class PrinterTests extends DottyTest {
2628
"""
2729

2830
checkCompile("typer", source) { (tree, context) =>
29-
implicit val ctx = context
31+
given Context = context
3032
val bar = tree.find(tree => tree.symbol.name == termName("bar")).get
3133
assertEquals("package object foo", bar.symbol.owner.show)
3234
}
@@ -43,7 +45,7 @@ class PrinterTests extends DottyTest {
4345
""".stripMargin
4446

4547
checkCompile("typer", source) { (tree, context) =>
46-
implicit val ctx = context
48+
given Context = context
4749
val bar @ Trees.DefDef(_, _, _, _, _) = tree.find(tree => tree.symbol.name == termName("bar2")).get
4850
assertEquals("Int & (Boolean | String)", bar.tpt.show)
4951
}

0 commit comments

Comments
 (0)