Skip to content

Commit f1ed7c8

Browse files
committed
Fix tests
1 parent b1d5bdb commit f1ed7c8

20 files changed

+41
-19
lines changed

compiler/src/dotty/tools/dotc/Run.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
7474
.addMode(Mode.ImplicitsEnabled)
7575
.setTyperState(ctx.typerState.fresh(ctx.reporter))
7676
ctx.initialize()(using start) // re-initialize the base context with start
77-
atPeriod(start.period) {
77+
atPeriod(ctx.period) {
7878
def addImport(ctx: Context, rootRef: ImportInfo.RootRef) =
7979
ctx.fresh.setImportInfo(ImportInfo.rootImport(rootRef))
8080
defn.RootImportFns.foldLeft(start.setRun(this))(addImport)

compiler/src/dotty/tools/repl/ReplCompiler.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,10 @@ class ReplCompiler extends Compiler {
4747
def importContext(imp: tpd.Import)(using Context, CState) =
4848
ctx.importContext(imp, imp.symbol)
4949

50-
def importPreviousRun(id: Int)(using Context, CState) = {
50+
def importPreviousRun(id: Int)(using Context, CState): Context = {
5151
// we first import the wrapper object id
5252
val path = nme.EMPTY_PACKAGE ++ "." ++ objectNames(id)
5353
def importWrapper(c: Context, importGiven: Boolean) = {
54-
assertSamePeriod()
5554
val importInfo = ImportInfo.rootImport(() =>
5655
requiredModuleRef(path), importGiven)(using c, c.cstate)
5756
c.fresh.setNewScope.setImportInfo(importInfo)

compiler/test/dotty/tools/CheckTypesTests.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +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}
8+
import dotc.core.Contexts._
99

1010
class CheckTypeTest extends DottyTest {
1111
@Test
@@ -29,6 +29,7 @@ class CheckTypeTest extends DottyTest {
2929
checkTypes(source, types: _*) {
3030
case (List(a, b, lu, li, lr, ls, la, lb), context) =>
3131
given Context = context
32+
given CState = context.cstate
3233

3334
assertTrue ( b <:< a)
3435
assertTrue (li <:< lu)
@@ -61,6 +62,7 @@ class CheckTypeTest extends DottyTest {
6162
checkTypes(source, List(typesA, typesB)) {
6263
case (List(sups, subs), context) =>
6364
given Context = context
65+
given CState = context.cstate
6466

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

compiler/test/dotty/tools/DottyTest.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ trait DottyTest extends ContextEscapeDetection {
8383
checkCompile("typer", gatheredSource) {
8484
(tree, context) =>
8585
given Context = context
86+
given CState = context.cstate
87+
8688
val findValDef: (List[tpd.ValDef], tpd.Tree) => List[tpd.ValDef] =
8789
(acc , tree) => {
8890
tree match {

compiler/test/dotty/tools/DottyTypeStealer.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package dotty.tools
33
import dotc.ast.tpd
44
import dotc.core.Names._
55
import dotc.ast.tpd._
6-
import dotc.core.Contexts.Context
6+
import dotc.core.Contexts._
77
import dotc.core.Decorators._
88
import dotc.core.Types.Type
99

@@ -17,6 +17,7 @@ object DottyTypeStealer extends DottyTest {
1717
checkCompile("typer", gatheredSource) {
1818
(tree, context) =>
1919
given Context = context
20+
given CState = context.cstate
2021
val findValDef: (List[ValDef], tpd.Tree) => List[ValDef] =
2122
(acc , tree) => tree match {
2223
case t: ValDef if t.name.startsWith(dummyName) => t :: acc

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

Lines changed: 2 additions & 1 deletion
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, ctx}
7+
import dotc.core.Contexts._
88
import dotc.core.Comments.{ContextDoc, ContextDocstrings}
99
import dotc.core.Phases.Phase
1010
import dotc.Compiler
@@ -59,6 +59,7 @@ trait DottyBytecodeTest {
5959
/** Checks source code from raw strings */
6060
def checkBCode(scalaSources: List[String], javaSources: List[String] = Nil)(checkOutput: AbstractFile => Unit): Unit = {
6161
given Context = initCtx
62+
given CState = initCtx.cstate
6263

6364
val compiler = new Compiler
6465
val run = compiler.newRun

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import org.junit.Assert._
1111
class DesugarTests extends DottyTest {
1212
import tpd._
1313

14-
private def validSym(sym: Symbol)(using Context): Unit = {
14+
private def validSym(sym: Symbol)(using Context, CState): Unit = {
1515
assert(
1616
// remaining symbols must be either synthetic:
1717
sym.is(Synthetic) ||
@@ -24,6 +24,7 @@ class DesugarTests extends DottyTest {
2424
@Test def caseClassHasCorrectMembers: Unit =
2525
checkCompile("typer", "case class Foo(x: Int, y: String)") { (tree, context) =>
2626
given Context = context
27+
given CState = context.cstate
2728
val ccTree = tree.find(tree => tree.symbol.name == typeName("Foo")).get
2829
val List(_, foo) = defPath(ccTree.symbol, tree).map(_.symbol.info)
2930

@@ -39,6 +40,7 @@ class DesugarTests extends DottyTest {
3940
@Test def caseClassCompanionHasCorrectMembers: Unit =
4041
checkCompile("typer", "case class Foo(x: Int, y: String)") { (tree, context) =>
4142
given Context = context
43+
given CState = context.cstate
4244
val ccTree = tree.find(tree => tree.symbol.name == termName("Foo")).get
4345
val List(_, foo) = defPath(ccTree.symbol, tree).map(_.symbol.info)
4446

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +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}
11+
import core.Contexts._
1212

1313
class TreeInfoTest extends DottyTest {
1414

@@ -18,6 +18,7 @@ class TreeInfoTest extends DottyTest {
1818
def testDefPath: Unit = checkCompile("typer", "class A { def bar = { val x = { val z = 0; 0} }} ") {
1919
(tree, context) =>
2020
given Context = context
21+
given CState = context.cstate
2122
val xTree = tree.find(tree => tree.symbol.name == termName("x")).get
2223
val path = defPath(xTree.symbol, tree)
2324
assertEquals(List(

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

Lines changed: 1 addition & 1 deletion
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, CState, ctx}
7+
import dotty.tools.dotc.core.Contexts._
88
import dotty.tools.io.AbstractFile
99

1010

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import ast.Trees._
1010
import ast.desugar
1111
import ast.desugar._
1212
import core.Mode
13-
import Contexts.{Context, CState}
13+
import Contexts._
1414

1515
import scala.collection.mutable.ListBuffer
1616

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package dotc
33
package parsing
44

55
import ast.Trees._
6-
import core.Contexts.Context
6+
import core.Contexts._
77

88
trait DocstringTest extends DottyTest {
99

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package dotty.tools
22
package dotc
33
package parsing
44

5-
import dotty.tools.dotc.core.Contexts.Context
5+
import dotty.tools.dotc.core.Contexts._
66
import dotty.tools.dotc.ast.Trees._
77

88
import org.junit.Assert._

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package parsing
55
import dotty.tools.dotc._
66
import core._, ast._
77
import Trees._
8-
import Contexts.{Context, CState}
8+
import Contexts._
99

1010
object parsePackage extends ParserTest {
1111

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ 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}
8+
import dotty.tools.dotc.core.Contexts._
99

1010
import org.junit.Assert.assertEquals
1111
import org.junit.Test
@@ -29,6 +29,7 @@ class PrinterTests extends DottyTest {
2929

3030
checkCompile("typer", source) { (tree, context) =>
3131
given Context = context
32+
given CState = context.cstate
3233
val bar = tree.find(tree => tree.symbol.name == termName("bar")).get
3334
assertEquals("package object foo", bar.symbol.owner.show)
3435
}
@@ -46,6 +47,7 @@ class PrinterTests extends DottyTest {
4647

4748
checkCompile("typer", source) { (tree, context) =>
4849
given Context = context
50+
given CState = context.cstate
4951
val bar @ Trees.DefDef(_, _, _, _, _) = tree.find(tree => tree.symbol.name == termName("bar2")).get
5052
assertEquals("Int & (Boolean | String)", bar.tpt.show)
5153
}

compiler/test/dotty/tools/dotc/reporting/ErrorMessagesTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package dotty.tools
22
package dotc
33
package reporting
44

5-
import core.Contexts.Context
5+
import core.Contexts._
66
import scala.collection.mutable
77
import org.junit.Assert._
88

compiler/test/dotty/tools/dotc/reporting/UserDefinedErrorMessages.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package dotty.tools
22
package dotc
33
package reporting
44

5-
import dotty.tools.dotc.core.Contexts.Context
5+
import dotty.tools.dotc.core.Contexts._
66
import org.junit.Assert._
77
import org.junit.Test
88

@@ -24,6 +24,7 @@ class UserDefinedErrorMessages extends ErrorMessagesTest {
2424
""".stripMargin
2525
}.expect { (itcx, messages) =>
2626
given Context = itcx
27+
given CState = itcx.cstate
2728

2829
assertMessageCount(1, messages)
2930
val (m: NoExplanation) :: Nil = messages
@@ -48,6 +49,7 @@ class UserDefinedErrorMessages extends ErrorMessagesTest {
4849
""".stripMargin
4950
}.expect { (itcx, messages) =>
5051
given Context = itcx
52+
given CState = itcx.cstate
5153

5254
assertMessageCount(1, messages)
5355
val (m: NoExplanation) :: Nil = messages
@@ -73,6 +75,7 @@ class UserDefinedErrorMessages extends ErrorMessagesTest {
7375
""".stripMargin
7476
}.expect { (itcx, messages) =>
7577
given Context = itcx
78+
given CState = itcx.cstate
7679

7780
assertMessageCount(1, messages)
7881
val (m: NoExplanation) :: Nil = messages
@@ -95,6 +98,7 @@ class UserDefinedErrorMessages extends ErrorMessagesTest {
9598
""".stripMargin
9699
}.expect { (itcx, messages) =>
97100
given Context = itcx
101+
given CState = itcx.cstate
98102

99103
assertMessageCount(1, messages)
100104
val (m: NoExplanation) :: Nil = messages
@@ -117,6 +121,7 @@ class UserDefinedErrorMessages extends ErrorMessagesTest {
117121
""".stripMargin
118122
}.expect { (itcx, messages) =>
119123
given Context = itcx
124+
given CState = itcx.cstate
120125

121126
assertMessageCount(1, messages)
122127
val (m: NoExplanation) :: Nil = messages

compiler/test/dotty/tools/dotc/transform/TreeTransformerTest.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import org.junit.{Assert, Test}
66
import MegaPhase._
77
import ast.tpd
88
import core.Constants.Constant
9-
import core.Contexts.{Context, CState}
9+
import core.Contexts._
1010

1111
class TreeTransformerTest extends DottyTest {
1212

1313
@Test
1414
def shouldReturnSameTreeIfUnchanged: Unit = checkCompile("typer", "class A{ val d = 1}") {
1515
(tree, context) =>
1616
given Context = context
17+
given CState = context.cstate
1718
class EmptyTransform extends MiniPhase {
1819
override def phaseName: String = "empty"
1920
init(ctx.base, ctx.period.firstPhaseId, ctx.period.lastPhaseId)
@@ -30,6 +31,7 @@ class TreeTransformerTest extends DottyTest {
3031
def canReplaceConstant: Unit = checkCompile("typer", "class A{ val d = 1}") {
3132
(tree, context) =>
3233
given Context = context
34+
given CState = context.cstate
3335
class ConstantTransform extends MiniPhase {
3436

3537
override def transformLiteral(tree: tpd.Literal)(using Context, CState): tpd.Tree = tpd.Literal(Constant(2))
@@ -48,6 +50,7 @@ class TreeTransformerTest extends DottyTest {
4850
def canOverwrite: Unit = checkCompile("typer", "class A{ val d = 1}") {
4951
(tree, context) =>
5052
given Context = context
53+
given CState = context.cstate
5154
class Transformation extends MiniPhase {
5255

5356
override def transformLiteral(tree: tpd.Literal)(using Context, CState): tpd.Tree = tpd.Literal(Constant(-1))
@@ -74,6 +77,7 @@ class TreeTransformerTest extends DottyTest {
7477
def transformationOrder: Unit = checkCompile("typer", "class A{ val d = 1}") {
7578
(tree, context) =>
7679
given Context = context
80+
given CState = context.cstate
7781
class Transformation1 extends MiniPhase {
7882
override def phaseName: String = "transformationOrder1"
7983

@@ -116,6 +120,7 @@ class TreeTransformerTest extends DottyTest {
116120
def invocationCount: Unit = checkCompile("typer", "class A{ val d = 1}") {
117121
(tree, context) =>
118122
given Context = context
123+
given CState = context.cstate
119124
var transformed1 = 0
120125
class Transformation1 extends MiniPhase {
121126
override def phaseName: String = "invocationCount1"

compiler/test/dotty/tools/dotc/typer/DivergenceChecker.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class DivergenceCheckerTests extends DottyTest {
3434
checkTypes(source, List(types, elements)) {
3535
case (List(tpes, elements0), context) =>
3636
given Context = context
37+
given CState = context.cstate
3738

3839
val List(a, b, n, o, s, t2, i, l) = elements0.map(_.typeConstructor)
3940
val expectedCoveringSets = List(

compiler/test/dotty/tools/dotc/typer/SubtypingInvariantTests.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dotty.tools.dotc.typer
22

33
import dotty.tools.DottyTest
4-
import dotty.tools.dotc.core.Contexts.Context
4+
import dotty.tools.dotc.core.Contexts._
55
import dotty.tools.dotc.core.Types.TypeBounds
66
import dotty.tools.dotc.typer.ProtoTypes.newTypeVar
77
import org.junit.Test
@@ -12,6 +12,7 @@ class SubtypingInvariantTests extends DottyTest {
1212
def typeVarInvariant(): Unit = {
1313
checkCompile("typer", "class A") { (_, ctx0) =>
1414
given Context = ctx0
15+
given CState = ctx0.cstate
1516
val a = newTypeVar(TypeBounds.empty)
1617
val b = newTypeVar(TypeBounds.empty)
1718
assert(a <:< b)

compiler/test/dotty/tools/repl/ReplCompilerTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import java.util.regex.Pattern
44

55
import org.junit.Assert.{assertTrue => assert, _}
66
import org.junit.{Ignore, Test}
7-
import dotty.tools.dotc.core.Contexts.{Context, CState, ctx}
7+
import dotty.tools.dotc.core.Contexts._
88

99
class ReplCompilerTests extends ReplTest {
1010
import ReplCompilerTests._

0 commit comments

Comments
 (0)