Skip to content

Commit 14bbc37

Browse files
committed
reproduce scala#13994 in cmdTest
1 parent a433f47 commit 14bbc37

File tree

9 files changed

+83
-5
lines changed

9 files changed

+83
-5
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,6 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
304304

305305
def process()(using Context) = {
306306

307-
def parseSource()(using Context) =
308-
if (unit.isJava) new JavaParser(unit.source).parse()
309-
else new Parser(unit.source).parse()
310-
311307
def enterTrees()(using Context) =
312308
ctx.typer.lateEnter(unit.untpdTree)
313309
def typeCheckUnit()(using Context) =
@@ -321,7 +317,9 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
321317
if compiling then finalizeActions += (() => typeCheckUnit()(using typerCtx))
322318
else typeCheckUnit()(using typerCtx)
323319

324-
unit.untpdTree = parseSource()
320+
unit.untpdTree =
321+
if (unit.isJava) new JavaParser(unit.source).parse()
322+
else new Parser(unit.source).parse()
325323
val namerCtx =
326324
// inline body annotations are set in namer, capturing the current context
327325
// we need to prepare the context for inlining.

project/scripts/bootstrapCmdTests

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,10 @@ clear_out "$OUT"
8383
./bin/scalac -d "$OUT/out.jar" tests/pos/i12973.scala
8484
echo "Bug12973().check" | TERM=dumb ./bin/scala -cp "$OUT/out.jar" > "$tmp" 2>&1
8585
grep -qe "Bug12973 is fixed" "$tmp"
86+
87+
echo "testing -sourcepath with inlining"
88+
cwd=$(pwd)
89+
java_prop="pack.version.file=$cwd/dist/target/pack/VERSION"
90+
(cd "$cwd/tests/cmdTest-sbt-tests/sourcepath-with-inline" && "$SBT" "-D$java_prop" ";clean;prepareChanges;compile;copyChanges;compile")
91+
rm -rf "$cwd/tests/cmdTest-sbt-tests/sourcepath-with-inline/target"
92+
rm -rf "$cwd/tests/cmdTest-sbt-tests/sourcepath-with-inline/project/target"

tests/cmdTest-sbt-tests/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Readme
2+
3+
Do not use this directory for testing sbt projects in general, add a test case to `dotty/sbt-test`
4+
5+
This directory is for sbt tests that can not be reproduced with sbt scripted tests.
6+
7+
Adding a test here will reduce the performance of running all tests.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import java.util.Properties
2+
3+
val packProperties = settingKey[Properties]("The properties of the dist/pack command")
4+
5+
val prepareChanges = taskKey[Unit]("Copy changes to the src directory")
6+
val copyChanges = taskKey[Unit]("Copy changes to the src directory")
7+
8+
packProperties := {
9+
val prop = new Properties()
10+
IO
11+
.read(new File(sys.props("pack.version.file")))
12+
.linesIterator
13+
.foreach { line =>
14+
val Array(key, value) = line.split(":=")
15+
prop.setProperty(key, value)
16+
}
17+
prop
18+
}
19+
20+
prepareChanges := {
21+
val root = (ThisBuild / baseDirectory).value
22+
val src = root / "src" / "main" / "scala"
23+
val changes = root / "changes"
24+
println("copying changes/zz.original.scala to src/main/scala/a/zz.scala")
25+
IO.copyFile(changes / "zz.original.scala", src / "a" / "zz.scala")
26+
}
27+
28+
copyChanges := {
29+
val root = (ThisBuild / baseDirectory).value
30+
val src = root / "src" / "main" / "scala"
31+
val changes = root / "changes"
32+
println("copying changes/zz1.scala to src/main/scala/a/zz.scala")
33+
IO.copyFile(changes / "zz1.scala", src / "a" / "zz.scala")
34+
}
35+
36+
scalaVersion := packProperties.value.getProperty("version")
37+
38+
(Compile / scalacOptions) ++= Seq(
39+
"-sourcepath", (Compile / sourceDirectories).value.map(_.getAbsolutePath).distinct.mkString(java.io.File.pathSeparator),
40+
)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package a
2+
3+
object Foo: // note that `Foo` is defined in `zz.scala`
4+
class Local
5+
inline def foo(using Local): Nothing =
6+
???
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package a
2+
3+
object Foo: // note that `Foo` is defined in `zz.scala`
4+
class Local
5+
inline def foo(using Local): Nothing =
6+
???
7+
???
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=1.5.5
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package a
2+
3+
object Bar:
4+
given Foo.Local()
5+
def Bar = Foo.foo
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package a
2+
3+
object Foo: // note that `Foo` is defined in `zz.scala`
4+
class Local
5+
inline def foo(using Local): Nothing =
6+
???
7+
???

0 commit comments

Comments
 (0)