Skip to content

Commit 7a0ca56

Browse files
committed
Fix regression test for #12128
To properly reproduce #12128, the regression test has some atypical classpath requirements in addition to separate compilation.
1 parent c27b681 commit 7a0ca56

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,27 @@ class CompilationTests {
325325
compileFilesInDir("tests/init/neg", options).checkExpectedErrors()
326326
compileFilesInDir("tests/init/pos", options).checkCompile()
327327
compileFilesInDir("tests/init/crash", options.without("-Xfatal-warnings")).checkCompile()
328+
329+
// The regression test for i12128 has some atypical classpath requirements.
330+
// The test consists of three files: (a) Reflect_1 (b) Macro_2 (c) Test_3
331+
// which must be compiled separately. In addition:
332+
// - the output from (a) must be on the classpath while compiling (b)
333+
// - the output from (b) must be on the classpath while compiling (c)
334+
// - the output from (a) _must not_ be on the classpath while compiling (c)
335+
locally {
336+
val i12128Group = TestGroup("checkInit/i12128")
337+
val i12128Options = options.without("-Xfatal-warnings")
338+
val outDir1 = defaultOutputDir + i12128Group + "/Reflect_1/i12128/Reflect_1"
339+
val outDir2 = defaultOutputDir + i12128Group + "/Macro_2/i12128/Macro_2"
340+
341+
val tests = List(
342+
compileFile("tests/init/special/i12128/Reflect_1.scala", i12128Options)(i12128Group),
343+
compileFile("tests/init/special/i12128/Macro_2.scala", i12128Options.withClasspath(outDir1))(i12128Group),
344+
compileFile("tests/init/special/i12128/Test_3.scala", options.withClasspath(outDir2))(i12128Group)
345+
).map(_.keepOutput.checkCompile())
346+
347+
tests.foreach(_.delete())
348+
}
328349
}
329350
}
330351

tests/init/crash/i12128/Macro_2.scala renamed to tests/init/special/i12128/Macro_2.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import scala.quoted._
22
import scala.language.experimental.macros
33

4+
class Location(val line: Int)
5+
46
object MacroCompat {
57
trait LocationMacro {
68
inline implicit def generate: Location = ${ locationImpl() }

tests/init/crash/i12128/Reflect_1.scala renamed to tests/init/special/i12128/Reflect_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ trait Context: // Dummy scala.reflect.macros.Context
2020
def New(tpe: Type, arg: Tree): Tree
2121
}
2222

23-
def enclosingPosition: Location
23+
def enclosingPosition: Position
2424

2525
trait Mirror {
2626
def staticClass(name: String): universe.Type
2727
}
2828
val mirror: Mirror
2929

30-
class Location(val line: Int)
30+
class Position(val line: Int)

0 commit comments

Comments
 (0)