Skip to content

Commit 1c56090

Browse files
committed
test extractAPI of inline from sourcepath
1 parent 235b07c commit 1c56090

File tree

6 files changed

+52
-2
lines changed

6 files changed

+52
-2
lines changed

project/scripts/bootstrapCmdTests

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ IFS=':=' read -ra versionProps < "$cwd/dist/target/pack/VERSION" # temporarily s
9696
[ -n ${versionProps[2]} ] || die "Expected non-empty 'version' property in $cwd/dist/target/pack/VERSION"
9797
scala_version=${versionProps[2]}
9898

99-
echo "testing -sourcepath with inlining"
100-
# Here we will test that an inline method symbol loaded from the sourcepath (-sourcepath compiler option)
99+
echo "testing -sourcepath with incremental compile: inlining changed inline def into a def"
100+
# Here we will test that a changed inline method symbol loaded from the sourcepath (-sourcepath compiler option)
101101
# will have its `defTree` correctly set when its method body is required for inlining.
102102
# So far I have not found a way to replicate issue https://github.com/lampepfl/dotty/issues/13994
103103
# with sbt scripted tests, if a way is found, move this test there.
@@ -107,3 +107,17 @@ sbt_test_command="++${scala_version}!;clean;prepareSources;compile;copyChanges;c
107107
rm -rf "$cwd/tests/cmdTest-sbt-tests/sourcepath-with-inline/target"
108108
rm -rf "$cwd/tests/cmdTest-sbt-tests/sourcepath-with-inline/project/target"
109109
rm -f "$cwd/tests/cmdTest-sbt-tests/sourcepath-with-inline/src/main/scala/a/zz.scala"
110+
111+
echo "testing -sourcepath with incremental compile: hashing reference to changed inline def from an inline def"
112+
# Here we will test that a changed inline method symbol loaded from the sourcepath (-sourcepath compiler option)
113+
# will have its `defTree` correctly set when its method body is hashed by extractAPI, when referenced from another
114+
# inline method.
115+
# So far I have not found a way to replicate https://github.com/lampepfl/dotty/pull/12931#discussion_r753212124
116+
# with sbt scripted tests, if a way is found, move this test there.
117+
cwd=$(pwd)
118+
sbt_test_dir="$cwd/tests/cmdTest-sbt-tests/sourcepath-with-inline-api-hash"
119+
sbt_test_command="++${scala_version}!;clean;prepareSources;compile;copyChanges;compile"
120+
(cd "$sbt_test_dir" && "$SBT" "$sbt_test_command")
121+
rm -rf "$sbt_test_dir/target"
122+
rm -rf "$sbt_test_dir/project/target"
123+
rm -f "$sbt_test_dir/src/main/scala/a/zz.scala"
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: 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+
inline def bar = Foo.foo // `Bar.bar` is inline, it will hash the body of `Foo.foo`

0 commit comments

Comments
 (0)