Skip to content

Commit 0f2f837

Browse files
committed
reproduce #13994 in cmdTest
1 parent a433f47 commit 0f2f837

File tree

11 files changed

+90
-10
lines changed

11 files changed

+90
-10
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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,11 @@ 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="-Dpack.version.file=$cwd/dist/target/pack/VERSION"
90+
(cd "$cwd/tests/cmdTest-sbt-tests/sourcepath-with-inline" && "$SBT" "$java_prop" ";clean;prepareSources;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"
93+
rm -f "$cwd/tests/cmdTest-sbt-tests/sourcepath-with-inline/src/main/scala/a/zz.scala"

project/scripts/cmdTestsCommon.inc.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
set -eux
22

3-
SBT="./project/scripts/sbt" # if run on CI
3+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >& /dev/null && pwd)/../.."
4+
5+
SBT="$ROOT/project/scripts/sbt" # if run on CI
46
# SBT="sbt" # if run locally
57

68
SOURCE="tests/pos/HelloWorld.scala"

project/scripts/sbt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
set -e
33

44
# Usage:
5-
# ./sbt <cmd>
5+
# ./sbt <props*> <cmd>
66

7-
CMD="${1:?Missing sbt command}"
7+
if (( $# < 1 )); then
8+
echo "Missing sbt command"
9+
exit 1
10+
fi
811

912
# run sbt with the supplied arg
1013
sbt -J-XX:ReservedCodeCacheSize=512m \
1114
-DSBT_PGP_USE_GPG=false \
12-
-no-colors \
13-
"$CMD"
15+
"$@"

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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import java.util.Properties
2+
3+
val prepareSources = taskKey[Unit]("Copy changes to the src directory")
4+
val copyChanges = taskKey[Unit]("Copy changes to the src directory")
5+
6+
val srcDir = settingKey[File]("The directory to copy changes to")
7+
val changesDir = settingKey[File]("The directory to copy changes from")
8+
9+
srcDir := (ThisBuild / baseDirectory).value / "src" / "main" / "scala"
10+
changesDir := (ThisBuild / baseDirectory).value / "changes"
11+
12+
prepareSources := IO.copyFile(changesDir.value / "zz.original.scala", srcDir.value / "a" / "zz.scala")
13+
copyChanges := IO.copyFile(changesDir.value / "zz.new.scala", srcDir.value / "a" / "zz.scala")
14+
15+
(Compile / scalacOptions) ++= Seq(
16+
"-sourcepath", (Compile / sourceDirectories).value.map(_.getAbsolutePath).distinct.mkString(java.io.File.pathSeparator),
17+
)
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: 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: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import sbt._
2+
import Keys._
3+
4+
import java.util.Properties
5+
import java.io.File
6+
7+
object DottyInjectedPlugin extends AutoPlugin {
8+
override def requires = plugins.JvmPlugin
9+
override def trigger = allRequirements
10+
11+
private val packProperties = settingKey[Properties]("The properties of the dist/pack command")
12+
13+
override val projectSettings = Seq(
14+
packProperties := {
15+
val prop = new Properties()
16+
IO
17+
.read(new File(sys.props("pack.version.file")))
18+
.linesIterator
19+
.foreach { line =>
20+
val Array(key, value) = line.split(":=")
21+
prop.setProperty(key, value)
22+
}
23+
prop
24+
},
25+
scalaVersion := packProperties.value.getProperty("version")
26+
)
27+
}
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

0 commit comments

Comments
 (0)