Skip to content

Commit 020617f

Browse files
committed
change test to establish cyclic case, and solution
1 parent 8a1887c commit 020617f

File tree

5 files changed

+39
-5
lines changed

5 files changed

+39
-5
lines changed

sbt-test/tasty-compat/add-param-unroll2/a_v3/A.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ object A {
1010

1111
}
1212

13-
// C is the same compilation unit as A, and inlines B.caller, so its TASTy will see the forwarder
14-
// where the associated file came from source
13+
// C is the same compilation unit as A, and inlines B.caller, so its TASTy will attempt to
14+
// resolve the generated forwarder A.foo, which doesn't exist yet in typer phase.
15+
// issue a compilation error here, suggesting to move C to a separate compilation unit.
16+
// In a_v3_2/C.scala, demonstrate fixing the error by moving C to a separate compilation unit.
1517
object C {
16-
val res = B.caller
18+
val res: String = B.caller
1719
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package a
2+
3+
import scala.annotation.unroll
4+
5+
// modify A.scala and add a parameter to foo, and add C (in another file), third compile via Zinc
6+
object A {
7+
8+
def foo(s: String, x: Int, @unroll b: Boolean = true): String = s + x + b
9+
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package a
2+
import b.*
3+
4+
// C is a separate compilation unit to A, and inlines B.caller, so its TASTy will try to resolve
5+
// the generated A.foo forwarder, which will not exist yet in typer phase.
6+
// The unit will suspend, and in the second run, A.foo will be generated, so resolution will succeed.
7+
object C {
8+
val res: String = B.caller
9+
}

sbt-test/tasty-compat/add-param-unroll2/build.sbt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ lazy val commonSettings = Seq(
44

55
lazy val printSettings = Seq(
66
scalacOptions += "-Yprint-tasty",
7+
scalacOptions += "-Ydebug-error"
78
)
89

910
lazy val a_v1 = project.in(file("a_v1"))
@@ -22,7 +23,16 @@ lazy val a_v2 = project.in(file("a_v2"))
2223

2324
lazy val a_v3 = project.in(file("a_v3"))
2425
.settings(commonSettings)
26+
.settings(printSettings)
2527
.settings(
2628
Compile / unmanagedClasspath += (ThisBuild / baseDirectory).value / "v3-input",
2729
Compile / classDirectory := (ThisBuild / baseDirectory).value / "v3-output"
2830
)
31+
32+
lazy val a_v3_2 = project.in(file("a_v3_2"))
33+
.settings(commonSettings)
34+
.settings(printSettings)
35+
.settings(
36+
Compile / unmanagedClasspath += (ThisBuild / baseDirectory).value / "v3-input",
37+
Compile / classDirectory := (ThisBuild / baseDirectory).value / "v3_2-output"
38+
)

sbt-test/tasty-compat/add-param-unroll2/test

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44
# method B.caller, calling A.foo
55
> a_v2/compile
66
# compile library A via Zinc, for the third time, add a new parameter to A.foo, using @unroll to generate a forwarder
7-
# in the same file A.scala, define object C that inlines B.caller, it should succeed and resolve the new invisible forwarder
8-
> a_v3/compile
7+
# in the same file A.scala, define object C that inlines B.caller, it should fail to resolve the new invisible forwarder, as it is not visible yet
8+
-> a_v3/compile
9+
# compile library A via Zinc, for the third time (alternative scenario), add a new parameter to A.foo, using @unroll to generate a forwarder
10+
# in a new file C.scala, define object C that inlines B.caller, it should suspend the unit and then resolve the new invisible forwarder
11+
> a_v3_2/compile

0 commit comments

Comments
 (0)